python list

list 

list = [‘wrr’,’354’,’sere’]

 

1. Access list elements

 

list[0] returns the same elements as the list elements

The elements returned by list[0].title() are capitalized

list[-1] returns the last element

 

2. Modify, delete and add elements

list[0] = 'rrrrrrru' modifies the first element

list.append('uuuuu') appends an element to the end of the list

list.insert(0,'kkkkkk') add space at the beginning of the list and store the value in this place

del list[0] deletes the position of the element in the list

list1 = list.pop() removes the element at the end of the list, but can continue to use

list1 = list.pop(0) can also specify to delete elements

list.remove('sere') can also be used to delete elements according to the value (self-understanding is that you can use the element to receive this value and print it out)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325032153&siteId=291194637