Python List Methods Reference

Every Python list method with signature, return value and in-place flag

Searchable reference for all Python list methods — append, extend, insert, remove, pop, sort, reverse — showing each method's signature, return value, and whether it mutates the list in place.

Why does list.sort() return None?

list.sort() sorts the list in place and deliberately returns None to signal that it mutated the object rather than producing a new one. This is a Python convention for in-place methods. A common bug is writing items = items.sort(), which assigns None; to get a sorted copy use sorted(items), which returns a new list and leaves the original unchanged.

Python’s list is a mutable sequence with a small, fixed set of methods. The key thing to know is which ones mutate in place (and return None) versus which ones return a value. This is a searchable offline reference.

How it works

Each method is flagged as in-place or returns a value:

  • In-place, returns Noneappend, extend, insert, remove, sort, reverse, clear. These change the list itself; assigning their result (x = x.sort()) is a classic bug that stores None.
  • Returns a valuepop returns the removed element, index returns a position, count returns a tally, copy returns a new list.

The single most common mistake is items = items.sort(). Use items.sort() to sort in place, or sorted(items) for a new sorted list.

append vs extend

a = [1, 2]
a.append([3, 4])   # a -> [1, 2, [3, 4]]   (one nested element)

b = [1, 2]
b.extend([3, 4])   # b -> [1, 2, 3, 4]      (concatenated)

Notes

  • sort and reverse mutate in place and return None; their non-mutating counterparts are the built-ins sorted() and reversed().
  • pop() with no argument removes and returns the last element; pop(0) removes the first (which is O(n) — prefer collections.deque for queues).
  • copy() is a shallow copy — nested mutable objects are shared.
  • This reference covers all standard list methods; len, sorted, reversed are built-in functions, not list methods.