← Reference

List Methods

Methods available on Python list objects.

list.append()

Adds a single element to the end of a list, modifying it in-place

list.append(x)

list.clear()

Removes all elements from a list, making it empty in-place

list.clear()

list.copy()

Creates a shallow copy of a list

list.copy()

list.count()

Returns the number of times a specified value appears in a list

list.count(x)

list.extend()

Adds all elements from an iterable to the end of a list, modifying it in-place

list.extend(iterable)

list.index()

Returns the index of the first occurrence of a specified value in a list

list.index(x[, start[, end]])

list.insert()

Inserts an element at a specified position in a list, modifying it in-place

list.insert(i, x)

list.pop()

Removes and returns the element at the specified index in a list

list.pop([i])

list.remove()

Removes the first occurrence of a specified value from a list

list.remove(x)

list.reverse()

Reverses the elements of a list in-place, modifying the original list

list.reverse()

list.sort()

Sorts the elements of a list in-place, modifying the original list with optional key and reverse parameters

list.sort(*, key=None, reverse=False)