Python List append() Method
list.append(item) adds one item to the end of a list, changes the list in place and returns None.Use append() whenever you build a list one value at a time, for example while looping over input. The list grows by exactly one element, no matter what that element is, even another list.
| Syntax | my_list.append(item) |
|---|---|
| Parameters | item: any object to add |
| Returns | None (the list is modified in place) |
| Time complexity | O(1) on average |
How list.append() works
Python places the new item after the last one, so the new item gets the index len(my_list) - 1.
fruits = ["apple", "kiwi"]
fruits.append("mango")
print(fruits)
print(len(fruits))append() vs extend() vs +
| Tool | Adds | Changes the list in place? | Example result for [1] and [2, 3] |
|---|---|---|---|
append() | One item (a list stays one item) | Yes | [1, [2, 3]] |
extend() | Every item of an iterable | Yes | [1, 2, 3] |
+ | Every item of another list | No, makes a new list | [1, 2, 3] |
Examples you can run
Press Run, then edit the code and run it again.
Build a list in a loop
A common pattern: start with an empty list and append inside a loop.
squares = []
for n in range(1, 6):
squares.append(n * n)
print(squares)Expected output[1, 4, 9, 16, 25]
Appending a list adds one nested item
append() never unpacks its argument.
row = [1, 2]
row.append([3, 4])
print(row)
print(len(row))Expected output[1, 2, [3, 4]]
3
Common mistakes
Using the return value
✗ Wrong
cart = ["pen"]
cart = cart.append("book")
print(cart)✓ Right
cart = ["pen"]
cart.append("book")
print(cart)append() returns None. Call it on its own line and keep using the original list.
Passing several items
✗ Wrong
nums = [1]
nums.append(2, 3)✓ Right
nums = [1]
nums.extend([2, 3])
print(nums)Use extend([2, 3]) to add several items at once.
Python List append() Method: questions people ask
Does append() return a new list?
No. It returns None and changes the original list in place.
How do I add multiple items to a list in Python?
Use extend() with an iterable, or concatenate with +. append() always adds exactly one item.
Keep learning
Step-by-step lessons:
Python ListsPython List Methods
Related:
Python List MethodsPython Lists
More in list methods:
Python List extend() MethodPython List insert() MethodPython List remove() MethodPython List pop() MethodPython List clear() MethodPython List index() MethodPython List count() MethodPython List sort() Method See all →