A list is an ordered set of elements that can be added and removed at any time.
Use the Len () function to get the number of list elements.
The index is used to access the elements of each position in the list, starting at 0. If you want to take the last element, in addition to calculating the index location, you can also use 1 as index to get the last element directly. And so on, you can get the bottom 2nd, the bottom 3rd one.
The list is a mutable, ordered table, so you can append the element to the end of the list. You can also insert elements into the specified position, such as the index number 1. To delete the element at the end of the list, use the Pop () method. To delete the element at the specified position, use the pop (i) method, where I is the index position. To replace an element with another element, you can assign a value directly to the corresponding index position. The data types in the list can also be different. The list element can also be another list.
If a list does not have an element, it is an empty list with a length of 0.
1classmates = ['Mike',"Bob","Jon"]2 3 Print(len (classmates))4 5 Print(Classmates[0])6 Print(classmates[1])7 Print(classmates[2])8 9 Print(classmates[-1])Ten Print(classmates[-2]) One Print(classmates[-3]) A -Classmates.append ('Adam') -Classmates.insert (1,'Jack') the Classmates.pop () -Classmates.pop (1) - -CLASSMATES[1] ='Sarah' + -L = ['Apple', 123, True] + As = ['python','Java', ['ASP','PHP']] at -L = [] - Print(Len (L))
List and tuple of Python data types