all Python 3Lists (list)function
list.append
adding
Append a single item to the end of the list in place; returns None.
Syntax
lst.append(item)
It mutates the list in place and returns None, so lst = lst.append(x) is the classic way to lose your list. The argument is stored as one single element even when it is itself a list or a string — use extend to spread the contents out. Appending costs amortised O(1).
Examples
lst = [1, 2]
lst.append(3)
print(lst) # → [1, 2, 3]
lst.append([4, 5])
print(lst) # → [1, 2, 3, [4, 5]]
See also
Open in the full glossarydocs.python.orgReport an inaccuracy