list.append
Add an item to the end of the list.
Python 3.13
list.append(x)Parameters
- xAny
- The item to add.
Return value
Nothing (None); the list is changed in place.
Examples
Adding an item to the end
Python 3.13
my_list = [1, 2]
my_list.append(3)
print(my_list)[1, 2, 3]
A list is added as one item
Python 3.13
a = [1, 2]
a.append([3, 4])
print(a)[1, 2, [3, 4]]
Details
A list passed to append is added as a single item. To add its items one by one, use list.extend.
