Python Built-in List Functions
Function Description Syntax Example
append() Adds an element to the end of the list [Link](item) [1, 2].append(3) -> [1, 2, 3]
count() Counts occurrences of an element [Link](item) [1, 2, 2, 3].count(2) -> 2
clear() Removes all elements from the list [Link]() [1, 2, 3].clear() -> []
extend() Extends list with another iterable [Link](iterable) [1, 2].extend([3, 4]) -> [1, 2, 3, 4]
index() Returns index of first occurrence [Link](item) [1, 2, 3].index(2) -> 1
insert() Inserts element at index [Link](index, item) [1, 3].insert(1, 2) -> [1, 2, 3]
len() Returns number of elements len(list) len([1, 2, 3]) -> 3
pop() Removes and returns element at index [Link](index) [1, 2, 3].pop(1) -> 2, [1, 3]
remove() Removes first occurrence of item [Link](item) [1, 2, 3].remove(2) -> [1, 3]
reverse() Reverses the list in place [Link]() [1, 2, 3].reverse() -> [3, 2, 1]
sort() Sorts list in ascending order [Link]() [3, 1, 2].sort() -> [1, 2, 3]