The list.extend(iterable) method grows a list in place by appending every item from iterable, one after another. The official description matches the slice assignment mental model a[len(a):] = iterable. If you are new to lists themselves, start with the Python list tutorial, then come back here for in-place merging.
Tested on: Python 3.13.3; kernel 6.14.0-37-generic.
What does extend() do in Python?
You call extend on an existing list. Python iterates iterable and pushes each value onto the right-hand end of that same list. Nothing is copied into a hidden “new” list—the object you called extend on grows, and the method returns None. Any object that can be iterated—another list, a tuple, a set, a string, a dictionary (keys), a generator, etc.—works as long as iteration yields the items you really want in the list.
Python list extend() syntax
list.extend(iterable)iterable is required. There is no separate start index; new items always land after the current last element.
Basic list extend() example
Extend a list with another list
cities = ["Delhi", "Bhopal"]
more = ["Mumbai", "Pune"]
cities.extend(more)
print(cities)When you run it, you should see one list containing all four city names in order: the two from cities, then the two from more.
Check the updated list after extend()
extend mutates the original list object; variables that pointed at that list see the same longer list.
a = [1, 2]
b = a
a.extend([3])
print(a is b)
print(b)You should see True then [1, 2, 3]—b reflects the change because it is the same object as a.
extend() return value
Why extend() returns None
Mutating methods on built-in lists (extend, append, sort, reverse, …) return None so you do not confuse “a new collection” with “the same object, updated.”
nums = [0]
out = nums.extend([1, 2])
print(out)
print(nums)You should see None on the first line, then [0, 1, 2] on the second.
Common assignment mistake
data = [10, 20]
wrong = data.extend([30])
print(wrong)wrong becomes None, not a list. If you need a new list and a copy, build it with slicing, +, or list.copy() before extending, or use + / list() on the combined iterables instead.
Extend list with different iterables
Extend list with a tuple
row = [1, 2]
row.extend((3, 4))
print(row)You should see [1, 2, 3, 4].
Extend list with a set
Sets are unordered; extend pulls items in iteration order (arbitrary for a plain set). Sorting when you print is only for a stable demo:
base = ["x"]
base.extend({"b", "a"})
print(sorted(base))You should see ['a', 'b', 'x'] after sorting (your list tail order before sorted may differ).
Extend list with a string
A string is an iterable of one-character strings, so extend("ab") adds 'a' and 'b', not the whole string as one element.
codes = [10]
codes.extend("AB")
print(codes)You should see [10, 'A', 'B'].
Extend list with a dictionary
Iteration over a dict yields its keys only—values are not added.
fields = ["name"]
fields.extend({"age": 1, "role": 2})
print(fields)You should see ['name', 'age', 'role'].
Extend list with multiple lists
Call extend() multiple times
main = [1]
main.extend([2, 3])
main.extend([4])
print(main)You should see [1, 2, 3, 4].
Use + or itertools.chain() for a new list
When you must not touch the original sequences, build a new list instead of chaining several extend calls on a shared accumulator.
from itertools import chain
first = [1, 2]
second = [3, 4]
combined = list(chain(first, second))
print(combined, first, second)You should see [1, 2, 3, 4] for combined, while first and second stay [1, 2] and [3, 4]. A plain first + second also allocates a new list with the same merged values. See concatenate lists in Python for +, unpacking, and itertools.chain patterns.
Python append() vs extend()
Add one item with append()
basket = ["apple"]
basket.append("pear")
print(basket)You should see ['apple', 'pear'].
Add multiple items with extend()
basket = ["apple"]
basket.extend(["pear", "plum"])
print(basket)You should see ['apple', 'pear', 'plum'].
append() with list vs extend() with list
a = [1, 2]
a.append([3, 4])
print(a)
b = [1, 2]
b.extend([3, 4])
print(b)You should see [1, 2, [3, 4]] then [1, 2, 3, 4]. Use append when the new value is a single object (even if that object is a list); use extend when you want the iterable unpacked into separate items. See append vs extend in list for a side-by-side comparison.
extend() vs + vs +=
Use extend() to modify the same list
left = [1, 2]
extra = [3, 4]
left.extend(extra)
print(left, extra)You should see [1, 2, 3, 4] and [3, 4]—extra is unchanged.
Use + to create a new list
a = [1, 2]
b = [3, 4]
c = a + b
print(c, a, b)You should see c as [1, 2, 3, 4] while a and b are unchanged.
Use += as in-place extension
For lists, += with another iterable delegates to in-place extension semantics (like extend), not rebinding the name to a brand-new object for a mutable target.
a = [1, 2]
b = a
a += [3, 4]
print(a is b)
print(a)You should see True then [1, 2, 3, 4]. Contrast with a = a + [3, 4] when a was the only reference—+ creates a new list and rebinds a, so identity can change in other patterns; for clarity, prefer extend when you explicitly mean “grow this list.”
Common mistakes with list extend()
- Assigning
x = lst.extend(...)and expecting a list—you getNone. - Using
extendwith a string when you meant one element—useappend("Mumbai")orextend(["Mumbai"]). - Extending with a dict and expecting values—only keys are iterated.
- Calling
append(iterable)when you meantextend(iterable)—you get a nested single element. - Assuming
+mutates an existing list—it always builds a new list from the two operands.
Python list extend() quick reference table
| Goal | Pattern |
|---|---|
| Grow list in place with many items | lst.extend(iterable) |
| Add exactly one object (any type) | lst.append(obj) |
| New list, keep inputs unchanged | list(chain(a, b)) or a + b |
| In-place bulk add (alternate spelling) | lst += iterable (list + iterable) |
| Doc-level mental model | lst[len(lst):] = iterable |
Summary
list.extend(iterable) walks an iterable and appends each item to the same list, matching the slice assignment a[len(a):] = iterable. It returns None, so do not assign its result. Tuples, sets, strings, dicts, and other iterables all work, but strings add characters, dicts add keys, and sets iterate in arbitrary order. For a single nested object use append; for unpacking a sequence into separate tail elements use extend. Use + or itertools.chain when you need a fresh combined list without mutating the originals.

