Python - List Methods
The Python has a number of methods and functions that are available for use with lists. These methods and functions are listed below in alphabetical order. For more details about any one of these, please visit its page.
List Methods & Functions
Methods | Description |
---|---|
append() | Adds a specified element to the end of the list |
clear() | Deletes all elements from the list |
copy() | Creates a copy of the list into a new list |
count() | Returns the number of occurrence of a specified element in the list |
extend() | Adds an element or iterable at the end of the list |
index() | Returns the index of first occurrence of a specified element in the list |
insert() | Adds a specified element at specified index in the list |
pop() | Deletes an element at specified index or last element of the list |
remove() | Deletes first occurrence of a specified element in the list |
reverse() | Reverses order of all elements in the list |
sort() | Sorts elements of the list in ascending or descending order with specified sorting criteria |
Functions | Description |
len() | Returns total number of elements in the list |
list() | List function/constructor is used to create list from iterable like list, tuple, set, string and dictionary, etc. |