There are many ways to list types, and here are all the methods of the list type:
List.append (x)
Adds an element to the end of the list, equivalent to A[len (a):] = [x].
List.extend (L)
Adds all the elements from a given list to another list, equivalent to A[len (a):] = L.
List.insert (i, X)
Inserts an element at the specified location. The first parameter is the index of the element that is ready to be inserted before it, such as A.insert (0, X) is inserted before the entire list, while A.insert (Len (a), x) is equivalent to A.append (x).
List.remove (x)
Removes the first element in the list that has a value of x. If there are no such elements, an error is returned.
List.pop ([i])
Removes the element from the specified position in the list and returns it. If no index is specified, A.pop () returns the last element. The element is removed from the list. (The square brackets on both sides of the method indicate that this parameter is optional, rather than asking you to enter a pair of parentheses, you will often encounter such tags in the Python Library Reference Manual.) )
List.index (x)
Returns the index of the first element in the list that has a value of x. If there are no matching elements, an error is returned.
List.count (x)
Returns the number of times that X appears in the list.
List.sort ()
Sorts the elements in the list in place.
List.reverse ()
The elements in the table are inverted in place.
The following example shows most of the methods of a list
>>> a = [66.25, 333, 333, 1, 1234.5]>>> print A.count (333), A.count (66.25), A.count (' X ') 2 1 0>>> ; A.insert (2,-1) >>> a.append (333) >>> a[66.25, 333,-1, 333, 1, 1234.5, 333]>>> a.index (333) 1& Gt;>> A.remove (333) >>> a[66.25,-1, 333, 1, 1234.5, 333]>>> a.reverse () >>> a[333, 1234.5, 1, 333,-1, 66.25]>>> a.sort () >>> a[-1, 1, 66.25, 333, 333, 1234.5]