Skip to content
Python

List API Reference

Python list methods — mutable ordered sequences for storing and manipulating collections.

By EZ4Code Team

list

Mutable ordered sequence of arbitrary objects.

list.append(item)

Append item to the end of the list.

Returns: None

list.extend(iterable)

Extend the list by appending all items from iterable.

Returns: None

list.insert(index, item)

Insert item before the given index.

Returns: None

list.remove(item)

Remove the first occurrence of item. Raises ValueError if not found.

Returns: None

list.pop([index])

Remove and return item at index (default last). Raises IndexError if empty.

Returns: Any

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

Sort the list in place.

Returns: None

list.reverse()

Reverse the list in place.

Returns: None

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

Return first index of item. Raises ValueError if not found.

Returns: int

list.count(item)

Return the number of occurrences of item.

Returns: int

More Python API References