list.append()

list.append(x)
Returns: None · Updated March 13, 2026 · List Methods
lists methods mutation

The .append() method adds an element to the end of a list. It modifies the list in-place and returns None, meaning you don’t assign its result back to a variable. This is one of the most frequently used list operations in Python.

Syntax

list.append(x)

Parameters

ParameterTypeDefaultDescription
xanyThe element to add to the list. Can be of any type: int, str, float, list, dict, object, etc.

Examples

Basic usage

Add a single element to an existing list:

fruits = ["apple", "banana"]
fruits.append("cherry")
print(fruits)
# ['apple', 'banana', 'cherry']

Adding different types

Python lists are heterogeneous — you can mix types freely:

mixed = []
mixed.append(42)
mixed.append("hello")
mixed.append(3.14)
mixed.append({"key": "value"})
print(mixed)
# [42, 'hello', 3.14, {'key': 'value'}]

The nested list pitfall

A common mistake is appending a list expecting it to merge elements:

numbers = [1, 2, 3]
numbers.append([4, 5])
print(numbers)
# [1, 2, 3, [4, 5]]  # Not [1, 2, 3, 4, 5]!

# Use .extend() to merge elements
numbers = [1, 2, 3]
numbers.extend([4, 5])
print(numbers)
# [1, 2, 3, 4, 5]

This also applies to strings — appending a string adds the entire string as one element, not individual characters:

letters = ["a", "b"]
letters.append("cd")
print(letters)
# ['a', 'b', 'cd']

Common Patterns

Building a list dynamically

A common pattern involves looping and building a list:

squares = []
for i in range(5):
    squares.append(i ** 2)
print(squares)
# [0, 1, 4, 9, 16]

While list comprehensions are often preferred, .append() remains useful when the logic is complex:

results = []
for item in data:
    if item.is_valid():
        processed = item.transform()
        results.append(processed)

Queue simulation (with caveats)

Lists can simulate a queue using .append() for enqueueing:

queue = []
queue.append("task1")
queue.append("task2")
queue.append("task3")

# Dequeue with pop(0) — note: O(n) operation
current = queue.pop(0)
print(current)  # 'task1'
print(queue)   # ['task2', 'task3']

For performance-critical queue operations, consider collections.deque instead.

Appending None to signal completion

Sometimes you’ll append None as a sentinel value:

items = [1, 2, 3]
items.append(None)
# Useful for marking end of a sequence

See Also