Python List extend() Method

Learn Python list extend() method with examples. Add items from another list, tuple, set, string, or dictionary, and understand extend() vs append(), +, and +=.

Published

Updated

Read time 6 min read

Reviewed byDeepak Prasad

Python List extend() Method

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

text
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

python
cities = ["Delhi", "Bhopal"]
more = ["Mumbai", "Pune"]
cities.extend(more)
print(cities)
Output

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.

python
a = [1, 2]
b = a
a.extend([3])
print(a is b)
print(b)
Output

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.”

python
nums = [0]
out = nums.extend([1, 2])
print(out)
print(nums)
Output

You should see None on the first line, then [0, 1, 2] on the second.

Common assignment mistake

python
data = [10, 20]
wrong = data.extend([30])
print(wrong)
Output

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

python
row = [1, 2]
row.extend((3, 4))
print(row)
Output

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:

python
base = ["x"]
base.extend({"b", "a"})
print(sorted(base))
Output

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.

python
codes = [10]
codes.extend("AB")
print(codes)
Output

You should see [10, 'A', 'B'].

Extend list with a dictionary

Iteration over a dict yields its keys only—values are not added.

python
fields = ["name"]
fields.extend({"age": 1, "role": 2})
print(fields)
Output

You should see ['name', 'age', 'role'].


Extend list with multiple lists

Call extend() multiple times

python
main = [1]
main.extend([2, 3])
main.extend([4])
print(main)
Output

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.

python
from itertools import chain

first = [1, 2]
second = [3, 4]
combined = list(chain(first, second))
print(combined, first, second)
Output

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()

python
basket = ["apple"]
basket.append("pear")
print(basket)
Output

You should see ['apple', 'pear'].

Add multiple items with extend()

python
basket = ["apple"]
basket.extend(["pear", "plum"])
print(basket)
Output

You should see ['apple', 'pear', 'plum'].

append() with list vs extend() with list

python
a = [1, 2]
a.append([3, 4])
print(a)

b = [1, 2]
b.extend([3, 4])
print(b)
Output

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

python
left = [1, 2]
extra = [3, 4]
left.extend(extra)
print(left, extra)
Output

You should see [1, 2, 3, 4] and [3, 4]extra is unchanged.

Use + to create a new list

python
a = [1, 2]
b = [3, 4]
c = a + b
print(c, a, b)
Output

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.

python
a = [1, 2]
b = a
a += [3, 4]
print(a is b)
print(a)
Output

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 get None.
  • Using extend with a string when you meant one element—use append("Mumbai") or extend(["Mumbai"]).
  • Extending with a dict and expecting values—only keys are iterated.
  • Calling append(iterable) when you meant extend(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.


References


Frequently Asked Questions

1. What does list.extend(iterable) do in Python?

It adds every item produced by the iterable to the end of the list in order, mutating the same list object; the docs describe it as equivalent to a[len(a):] = iterable.

2. What does extend() return?

It always returns None because the list is updated in place; assigning result = my_list.extend(other) stores None in result by mistake if you expect a new list.

3. What is the difference between append and extend on a list?

append adds exactly one object to the tail; extend walks an iterable and adds each element—so append([1,2]) nests one list, while extend([1,2]) adds two separate items.

4. Should I use extend or + to combine lists?

Use extend (or += on the same list) when you want to grow an existing list in place; use + when you need a brand-new list and want to keep the originals unchanged.

5. Why does my list get single characters when I extend with a string?

Strings are iterables of one-character strings, so extend pulls each character as its own list element—wrap the string in a list if you meant one whole string item.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …