This article is mainly to share with you the Python list of functions & methods in detail, I hope to help everyone.
Python list Functions & methods
Python contains the following functions:
Serial Number |
function |
1 |
CMP (List1, List2) Compare two elements of a list |
2 |
Len (list) Number of list elements |
3 |
Max (list) Returns the maximum value of a list element |
4 |
MIN (list) Returns the minimum value of a list element |
5 |
List (seq) Convert a tuple to a list |
Python contains the following methods:
Serial Number |
Method |
1 |
List.append (obj) Add a new object at the end of the list |
2 |
List.count (obj) Count the number of occurrences of an element in a list |
3 |
List.extend (seq) Append multiple values from another sequence at the end of the list (extend the original list with a new list) |
4 |
List.index (obj) Find the index position of the first occurrence of a value from the list |
5 |
List.insert (index, obj) Inserting an object into a list |
6 |
List.pop (Obj=list[-1]) Removes an element from the list (the last element by default), and returns the value of the element |
7 |
List.remove (obj) To remove the first occurrence of a value in a list |
8 |
List.reverse () Reverse List of elements |
9 |
List.sort ([func]) Sort the original list |
Related recommendations:
List of Python lists
You should know the Python list to redo method
How arrays in the Python list are referenced