Python list append: Usage, Behavior, and Performance
How Python's list.append() works, what it returns, its time complexity, common mistakes, and when to use extend() or list comprehensions.

Python's list.append() method adds one element to the end of a list. It modifies the list in place, returns None, and has amortized O(1) time complexity. This makes it the standard way to build a list incrementally, but its in-place behavior and None return can be surprising, especially if you are used to chainable APIs.
The append() Method and Its Return Value
append() is a method on the list type. It takes one argument and adds that argument as a single element to the end of the list. The method returns None, not the modified list. This is a frequent point of confusion, especially for developers coming from languages where mutating methods return the original object for chaining.
numbers = [1, 2, 3]
result = numbers.append(4)
print(numbers) # [1, 2, 3, 4]
print(result) # NoneBecause append() returns None, you cannot chain it like numbers.append(4).append(5). If you need to add more than one element, call append() once per element or use extend().
append() Mutates the List in Place
append() does not create a copy. Any variable that references the same list object will see the change. This matters when you pass a list to a function and append inside that function.
def add_item(items, item):
items.append(item)
cart = []
add_item(cart, "apple")
print(cart) # ['apple']If you need to avoid modifying the original list, make a copy first, for example new_items = items.copy(), and call append() on the new list.
Time Complexity and Memory Allocation
append() runs in amortized O(1) time. In CPython, lists are dynamic arrays: appending stores one reference at the end, and when the array is full, Python allocates a larger array and copies existing references. That occasional resize is amortized over many appends, so the average cost per operation stays constant.
Python may also overallocate list capacity to reduce the frequency of resizes. This means a list can use more memory than the exact number of elements requires. The exact overallocation strategy is an implementation detail and can change between Python versions.
Because append() stores references, appending a mutable object does not copy that object; later changes to the object are visible through the list.
For most applications, append() is the right choice for building a list incrementally. If you know the final size in advance, preallocating with [None] * n and assigning by index can avoid reallocations, but that is rarely necessary unless you are working with very large collections and have measured a bottleneck.
Common Mistake: append() vs extend()
A frequent error is using append() when you want to add multiple elements from an iterable. append() adds the iterable as a single element, while extend() adds each element individually.
numbers = [1, 2]
more = [3, 4]
numbers.append(more)
print(numbers) # [1, 2, [3, 4]]
numbers = [1, 2]
numbers.extend(more)
print(numbers) # [1, 2, 3, 4]If you use append() with a list, you get a nested list. This is often not what you intended. extend() is the correct method when you want to merge an iterable into the existing list. The same distinction applies to strings: append("abc") adds the string as one element, while extend("abc") adds the characters 'a', 'b', and 'c' separately.
Using append() in Loops
append() is commonly used inside loops to collect results. Because it is amortized O(1), it is efficient even for large loops. A typical pattern is:
squares = []
for n in range(10):
squares.append(n ** 2)This is clear and idiomatic. A list comprehension is often more concise for simple transformations, but append() gives you more flexibility when the logic is complex or when you need to conditionally add elements.
filtered = []
for value in source:
if value > 0:
filtered.append(value)For more involved loops, append() is often easier to read than a long comprehension. Prefer a comprehension or extend() with a generator expression when they make the code clearer, but do not sacrifice readability for micro-optimizations.
Appending While Iterating: Avoid It
Modifying a list while iterating over it is dangerous. If you append to a list inside a for loop that iterates over the same list, the iterator checks the list's current length at each step, so the loop can keep finding new items and grow until memory runs out.
# This loop can keep appending until memory runs out
items = [1, 2, 3]
for item in items:
items.append(item)To avoid this, iterate over a copy of the list, or collect new items in a separate list and extend the original after the loop.
items = [1, 2, 3]
new_items = []
for item in items:
if item < 3:
new_items.append(item * 10)
items.extend(new_items)This pattern is safe and clear. Appending to a list while iterating over a different list is fine.
Alternatives: extend, +=, and List Comprehensions
extend() is the primary alternative when you need to add multiple elements. The += operator on a list is equivalent to extend(): it mutates the list in place and adds all elements from the right-hand iterable.
a = [1, 2]
a += [3, 4]
print(a) # [1, 2, 3, 4]List comprehensions are a declarative way to build a new list without explicitly calling append(). They are often more readable for simple transformations, but they always create a new list, so they are not a drop-in replacement when you need to mutate an existing list.
| Operation | Use case | Returns a new list | Mutates in place |
|---|---|---|---|
append(x) | Add one element x | No | Yes |
extend(iterable) | Add every item from an iterable | No | Yes |
+= iterable | Add every item from an iterable | No | Yes |
| List comprehension | Build a new list from an iterable | Yes | No |
Choose append() when you have one element to add. Use extend() or += when you have an iterable. Use a list comprehension when you are building a new list from an existing iterable and the transformation is simple enough to express in one expression.
Try matching browser tools
All toolsSmall utilities that fit Python work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Python guides
All Python guidesPython iter(): How the Built-in Function Works
Explains Python's iter() built-in: how it creates iterators, the two-argument sentinel form, custom iterator classes, and common edge cases.
Python Pika: Queues, Exchanges, Routing Keys, and Acknowledgements
Learn how to use Python's Pika client with RabbitMQ: declare queues and exchanges, publish with routing keys, consume messages, and handle acknowledgements reliably.
Python Kafka: kafka-python vs Confluent Client
python kafka python vs confluent kafka: Compare kafka-python and Confluent Kafka Python clients: API differences, performance, feature coverage, and when to choose eac...
Python Kafka Offsets, Partitions, and Manual Commits
Learn how Kafka offsets and partitions work and how to manually commit offsets in Python consumers with kafka-python and confluent-kafka. Covers sync vs async commits, rebalances, and seeking.
More in Python
All Python guidesThe guides filed next to this one in Python, in library order.