Last modified: May 23, 2026
Python List Extend: A Complete Guide
Python lists are powerful. They store data in an ordered way. You often need to add elements. The extend() method helps you do this. It adds all items from an iterable to the end of a list.
This guide explains extend() clearly. You will see how it works. You will learn its use cases. We also compare it to other methods. Let's start.
What is Python List Extend?
The extend() method adds elements from another iterable. An iterable can be a list, tuple, set, or string. It modifies the original list. It does not return a new list.
The syntax is simple: list.extend(iterable). You call it on your list. You pass the iterable inside parentheses. The method adds each element one by one.
# Basic example of extend()
fruits = ["apple", "banana"]
more_fruits = ["cherry", "date"]
fruits.extend(more_fruits)
print(fruits)
['apple', 'banana', 'cherry', 'date']
The original list fruits changed. It now has four items. The more_fruits list stayed the same. This is important to remember.
How Extend Differs from Append
Many beginners confuse extend() and append(). They are different. append() adds one element to the end. It treats the argument as a single object.
With extend(), you add multiple elements. It unpacks the iterable. Each item becomes a new element in the list.
# Compare append vs extend
list_a = [1, 2, 3]
list_b = [4, 5]
list_a.append(list_b)
print("After append:", list_a)
list_c = [1, 2, 3]
list_d = [4, 5]
list_c.extend(list_d)
print("After extend:", list_c)
After append: [1, 2, 3, [4, 5]]
After extend: [1, 2, 3, 4, 5]
Notice the difference.append() added the list as one element. extend() added each number separately. Use append() for single items. Use extend() for multiple items.
Using Extend with Different Iterables
The extend() method works with any iterable. Let's see examples.
Extend with a Tuple
# Extend with a tuple
numbers = [1, 2]
more_numbers = (3, 4)
numbers.extend(more_numbers)
print(numbers)
[1, 2, 3, 4]
Extend with a Set
# Extend with a set
colors = ["red", "blue"]
new_colors = {"green", "yellow"}
colors.extend(new_colors)
print(colors)
['red', 'blue', 'yellow', 'green']
Note: Sets are unordered. The order of added items may vary.
Extend with a String
# Extend with a string
letters = ["a", "b"]
word = "cd"
letters.extend(word)
print(letters)
['a', 'b', 'c', 'd']
Strings are iterables. Each character becomes a separate element. This is useful for splitting text.
Extend vs Concatenation
You can also use the + operator to combine lists. This creates a new list. It does not modify the original list.
# Concatenation with +
list1 = [1, 2]
list2 = [3, 4]
new_list = list1 + list2
print("list1:", list1)
print("new_list:", new_list)
list1: [1, 2]
new_list: [1, 2, 3, 4]
Use extend() when you want to change the original list. Use + when you need a new list. For large lists, extend() is faster. It does not create a copy.
Practical Examples of Extend
Let's see real-world uses. extend() is common in data processing.
Building a List from Multiple Sources
# Building a list from multiple sources
tasks = ["task1", "task2"]
daily_tasks = ["task3", "task4"]
weekly_tasks = ["task5", "task6"]
tasks.extend(daily_tasks)
tasks.extend(weekly_tasks)
print(tasks)
['task1', 'task2', 'task3', 'task4', 'task5', 'task6']
Merging User Input
# Merge user input
user_names = ["Alice", "Bob"]
new_users = ["Charlie", "Diana"]
user_names.extend(new_users)
print("All users:", user_names)
All users: ['Alice', 'Bob', 'Charlie', 'Diana']
Common Mistakes with Extend
Avoid these errors. They can break your code.
Forgetting to Assign the Result
extend() returns None. It modifies the list in place. Do not assign it to a variable.
# Wrong way
my_list = [1, 2]
result = my_list.extend([3, 4])
print(result) # Output: None
print(my_list) # This is correct
None
[1, 2, 3, 4]
Passing a Non-Iterable
If you pass a single integer, it will cause an error. extend() expects an iterable.
# This causes an error
my_list = [1, 2]
my_list.extend(3) # TypeError: 'int' object is not iterable
Use append() for single items. Or wrap the integer in a list.
Performance Considerations
extend() is efficient. It adds elements in one operation. For large lists, it is faster than using a loop with append().
# Compare performance
import time
big_list = list(range(1000000))
new_items = list(range(1000000))
start = time.time()
big_list.extend(new_items)
end = time.time()
print("Extend time:", end - start)
Use extend() for bulk additions. It reduces overhead. Your code runs faster.
Extend and List Operations
Understanding extend() helps with other list tasks. For example, you might need to remove duplicates after merging. Check our guide on Convert Python List to Set: Remove Duplicates.
If you work with many lists, review Python List Operations Guide for Beginners. It covers all basic methods.
For advanced management, see Python List of Objects: Create, Manage, and Use.
Conclusion
The extend() method is essential for Python lists. It adds multiple items efficiently. It modifies the list in place. Use it with any iterable. Avoid common mistakes like assigning the result. Practice with different data types. This method saves time and keeps your code clean.
Now you know how to use extend(). Try it in your projects. It will make your list operations smoother.