The list in Python is a set of ordered collections that can be added and removed at any time.
To get the length of the list, you can use the Len () method.
To access an element in the list can be accessed by subscript, and the subscript starts at 0.
Of course, if the last element of the access can be accessed using the subscript 1, the second-lowest one can be accessed using-2.
Adding elements to the end of the list element can be increased using the Append () method.
Use Insert (Index,value) to insert an element into the specified position.
Deleting elements at the end of the list can use the Pop () method
Deleting the first few elements of the list can be deleted using the pop (i) method.
Of course the list can store different types of elements.
Here's a look at the specific example:
stulist=[' Zhangsan ', ' Lisi ', ' Wangwu ']print len (stulist) print stulist[1];p rint stulist[-1]stulist.append (' Sunliu ') Print Stulist[-1]stulist.insert (1, ' Mary ') print Stulist[1]stulist.pop () print stulist[-1]stulist.pop (1) Print stulist [1]numlist = [B, ' C ', ' String ']print numlistprint numlist[0]Running results such as:
List in Python