Use Python’s list.extend(iterable) to append each item from another iterable to an existing list. Unlike append(), extend() adds the iterable’s elements individually and returns None.
Python list.extend() syntax and return value
list1.extend(list2)
The general syntax is items.extend(iterable). It takes exactly one iterable argument, appends its elements in iteration order, changes items in place and returns None. Do not assign items = items.extend(other), because that replaces the variable with None.
Tuples, sets, strings and generators can be passed directly to extend(). For example:
- items.extend(tuple_data)
- items.extend(iterable)
Extend a list with another list
# Creating a First List
workers_name = ['John', 'Neil', 'Adam']
print("Content of workers_name list: ", workers_name)
# Another list of city
department = ['Admin', 'Manager']
print("Contents of department list: ", department)
department.extend(workers_name)
# Extended List
print('Contents of department list after department.extend(workers_name):', department)
The output will be
Output:
Content of workers_name list: ['John', 'Neil', 'Adam']
Content of department list: ['Admin', 'Manager']
Contents of department list after department.extend(workers_name): ['Admin', 'Manager', 'John', 'Neil', 'Adam']
Extend a list with a tuple or set
# Creating a First list
list_1 = ['Learn', 'Python', 'Well']
print("List is: ",list_1)
# Creating a tuple
tuple_data = ('Pickup', 'Brain')
print("Tuple is: ",tuple_data)
# Creating a set
set_data = {'Knowledge', 'is', 'Wealth'}
print("Set is: ",set_data)
# Appending element of tuple
list_1.extend(tuple_data)
print('List and Tuple data: ', list_1)
# Appending element of set
list_1.extend(set_data)
print('List and Set data: ', list_1)
The output will be
Output:
List is: ['Learn', 'Python', 'Well']
Tuple is: ('Pickup', 'Brain')
Set is: (order may vary)
List and Tuple data: ['Learn', 'Python', 'Well', 'Pickup', 'Brain']
List and Set data: (the final three items may appear in any order)
extend() iterates through the supplied iterable; it does not first convert every argument into a list. Sets have no guaranteed iteration order, so their displayed element order can vary.
When to use extend() instead of append()
Use extend() to add each item from a list, tuple or generator. Use append() to add the entire object as one element. For example, a = [1]; a.extend([2, 3]) produces [1, 2, 3], while a = [1]; a.append([2, 3]) produces [1, [2, 3]]. Both modify the original list and return None.
Common errors and troubleshooting
TypeError: extend(5) fails because an integer is not iterable; use append(5) or extend([5]). Unexpected characters: extend('hi') adds 'h' and 'i' separately. Unexpected None: result = items.extend(values) sets result to None; inspect items instead. Unpredictable set order: use extend(sorted(my_set)) for reproducible order.
Conclusion
Choose extend() when each item of an iterable should become a separate list element. Choose append() when the entire argument should become one element. Neither method returns the modified list.
For the official method contract, see the Python documentation on list methods.
Frequently asked questions about list.extend()
Does extend() create a new list? No. It modifies the existing list and returns None. How is it different from +? For two lists, a + b produces a new list; a.extend(b) modifies a and accepts any iterable. Can it add an integer? Not directly: use append(5) or extend([5]).
Worked example: generators, strings and self-extension
A generator is consumed as its values are added; a second extension with the same exhausted generator adds nothing. A string is iterable, so its characters are added individually. Extending a list with itself duplicates its current elements; use this intentionally and be mindful of memory use.
numbers = [1, 2]
more = (n for n in [3, 4])
numbers.extend(more)
assert numbers == [1, 2, 3, 4]
numbers.extend(more) # Generator is exhausted
assert numbers == [1, 2, 3, 4]
letters = ['A']
letters.extend('BC')
assert letters == ['A', 'B', 'C']
values = [1, 2]
values.extend(values)
assert values == [1, 2, 1, 2]Performance and practical precautions
Extending a Python list with k elements generally takes O(k) amortized time, excluding work needed to generate the elements. A set has no guaranteed order; use sorted(my_set) when the resulting order matters. Extending with a very large or unbounded generator may consume substantial memory or never finish. If you need only a single nested object, use list.append(); to place items at a specific position, see list.insert().

C P Gupta is a YouTuber and Blogger. He is expert in Microsoft Word, Excel and PowerPoint. His YouTube channel @pickupbrain is very popular and has crossed 9.9 Million Views.