Master Code
On The Go

Learn. Practice. Build.

Home › Code Snippets › Python › Reference › append()

Python Reference

list.append()

Add a single item to the end of a list. Mutates in place, returns None.

Last updated: October 2026

append() adds one item to the end of a list. It mutates the list in place and returns None — never assign the result.

Full definition: list.append(x) adds a single item x to the end of a list. It modifies the list in place and returns None. It always adds exactly one element.

🎬 Live Example

Five common append patterns. Click any button to see the output.

Input:

                
Output:

            

💡 append always adds exactly one element — even if that element is a list.

📝

Basic Syntax

list.append(x)

# x — any object
# Mutates list in place
# Returns None
# Adds exactly ONE element (even if x is a list)

🎯 Parameters & Return

Item Type Description
xanyThe single item to add to the end.
ReturnNoneAlways None — mutates the list in place.
1

Basic Usage

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

nums = [1, 2, 3]
nums.append(4)
# nums: [1, 2, 3, 4]
2

Return Value Trap

nums = [1, 2]

# ❌ WRONG
nums = nums.append(3)
# nums is now None!

# ✅ CORRECT
nums.append(3)
# nums: [1, 2, 3]

Common bug: Never assign the result of append. It always returns None.

3

append vs extend

a = [1, 2]
a.append([3, 4])
# [1, 2, [3, 4]]  ← nested

b = [1, 2]
b.extend([3, 4])
# [1, 2, 3, 4]  ← flattened

Rule of thumb: append = "add this thing." extend = "add all items from this iterable."

4

Building a List in a Loop

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

# Pythonic alternative:
squares = [i ** 2 for i in range(5)]
5

Real-World: Collecting API Results

users = []

for page in range(1, 4):
    response = fetch_users(page)
    for user in response:
        users.append(user)

# All users across pages now in one list

🎯 append vs extend vs insert vs +

Method Adds Complexity
append1 item at endO(1)
extendMany items at endO(k) where k = len(iterable)
insert1 item at indexO(n)
+Concatenated listO(n + m), creates new list

⚠️ Common Mistakes

❓ Frequently Asked Questions

What does append() do in Python?

list.append(x) adds a single item to the end of a list. It modifies the list in place and returns None.

What is the difference between append and extend?

append adds its argument as a single element. extend iterates over its argument and adds each element individually. append([1,2]) adds one nested list; extend([1,2]) adds two items.

What is the difference between append and insert?

append always adds to the end. insert adds at a specific index. append is O(1); insert is O(n) because it shifts elements.

Does append return the list?

No. append returns None. It mutates the list in place. Writing my_list = my_list.append(x) will set my_list to None.

Can append add multiple items at once?

No. append takes exactly one argument. Use extend to add multiple items, or call append multiple times.

🎯 What's Next?

← All Python Reference