add

list.append

Appends a single item x to the end of the list, mutating it in place. Always returns None — it does not return the modified list.

list.append(x)

Parameters

Parameter Purpose
x The single object to append; can be any type, including another list (nested).
(no keyword args) append() takes exactly one positional argument — no options.

Examples

>>> nums = [1, 2, 3]
>>> nums.append(4)
>>> nums
[1, 2, 3, 4]

Basic append of a single int.

>>> lst = [1, 2]
>>> lst.append([3, 4])
>>> lst
[1, 2, [3, 4]]

append adds the argument as ONE element — use extend to unpack an iterable.

>>> x = [].append(1)
>>> print(x)
None

append returns None — never assign its result.

>>> lst = [1]
>>> lst.append('a')
>>> lst
[1, 'a']

Lists are heterogeneous — any type works.

Gotcha

append mutates in place and returns None. Writing `x = lst.append(1)` sets x to None. Also, append([1,2]) adds the list as a nested element — use extend for flattening.

Related methods

← All Python list methods · Dict methods · list vs tuple vs set