Adds an element at the end of the list.
append()
list = [1, 2, 3] list.append(4) # Output [1, 2, 3, 4]
Removes all the elements from the list.
clear()
list = [1, 2, 3] list.clear() # Output []
Returns a copy of the list.
copy()
list = [1, 2, 3] copied_list = list.copy() # Output [1, 2, 3]
Returns the number of elements with the specified value.
Output
count()
~~~
list = [1, 2, 3, 3]
total_count = list.count(3)
2
Add the elements of a list (or any iterable), to the end of the current list.
extend()
Returns the index of the first element with the specified value.
index()
Adds an element at the specified position.
insert()
Removes the element at the specified position.
pop()
Removes the first item with the specified value.
remove()
Reverses the order of the list.
reverse()
Sorts the list.
sort()