Python list.extend() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
list method

Definition

extend(iterable) loops over the iterable and adds each of its items to the end of the list, in order. The list is changed in place and the method returns None.

Any iterable works: another list, a tuple, a range, a dict (which gives its keys), a generator, or a string (which gives its characters). A value that is not iterable, such as an int, raises TypeError.

list.extend() is an instance method of the built-in list type: call it on a list with dot notation, such as cart.extend(...). No import is needed.

Syntax

Pass one iterable; its items are appended one by one.

python
lst.extend(iterable)
CallWhat it does
[1].extend([2, 3])Returns None; the list becomes [1, 2, 3].
["a"].extend("bc")Returns None; the list becomes ['a', 'b', 'c']: one item per character.
[1].extend(5)Raises TypeError: an int is not iterable.

lst += iterable does the same in-place extend. lst = lst + other is different: it builds a new list and only accepts another list.

Method signatures
python
list.extend(iterable)
# returns: None; every item of iterable is appended in order

Parameters

ParameterDescription
iterableAny iterable. Its items are added one at a time, so a string adds characters and a dict adds keys. Use d.values() or d.items() for the other parts of a dict.

Return Value

Return ValueDescription
NoneAlways None. The list is longer by the number of items the iterable produced.

Python Examples

Example 1 — Merge Grocery Items Into a Cart

Extend with a list, then see what happens when a single string is passed by mistake.

python
cart = ["bread", "eggs"]
print(cart.extend(["jam", "butter"]))
print(cart)

cart.extend("tea")
print(cart)

del cart[-3:]
cart.extend(["tea"])
print(cart)

How It Works

  1. Nothing comes back. extend() returns None, while the two new groceries are added to cart itself.
  2. Two separate items. "jam" and "butter" join the cart as two elements, not as one nested list.
  3. Strings split into letters. A string is iterable one character at a time, so extend("tea") adds three single letters.
  4. Undo and fix. del cart[-3:] removes the three letters, and wrapping the word in a list adds "tea" as one item.

Example 2 — Collect Ticket Numbers From Many Sources

Extend the same list with a tuple, a range, a dict, and a generator expression.

python
tickets = [101]
tickets.extend((102, 103))
tickets.extend(range(104, 107))
tickets.extend({"VIP1": "Ana", "VIP2": "Raj"})
tickets.extend(n * 100 for n in (2, 3))
print(tickets)
print(len(tickets))

How It Works

  1. Tuple and range. The tuple adds 102 and 103, and range(104, 107) adds 104, 105, and 106 (the stop value 107 is excluded).
  2. Dicts give keys. Iterating a dict yields its keys, so "VIP1" and "VIP2" are added and the names are ignored.
  3. Generators work too. The generator expression produces 200 and 300 on the fly; no temporary list is needed.
  4. Ten flat items. Every source was unpacked into the single list, which mixes ints and strings in arrival order.

Example 3 — Add Round Scores With += and +

+= extends the same list and accepts a tuple; + builds a new list and needs a list on both sides.

python
scores = [120, 95]
alias = scores

scores += (88, 140)
print(scores, alias is scores)

try:
    scores = scores + (60,)
except TypeError:
    print("list + tuple raises TypeError")

scores = scores + [60]
print(scores, alias is scores)
print(alias)

How It Works

  1. += is extend. scores += (88, 140) extends the existing list in place, so alias is still the very same object.
  2. + is pickier. Concatenation with + only joins a list with another list, so adding a tuple raises TypeError.
  3. + makes a new list. scores + [60] builds a fresh list and rebinds scores to it, so the identity check is now False.
  4. The alias is left behind. alias still points to the older list, which never received 60.

Frequently Asked Questions

extend(iterable) adds each item of the iterable separately. append(x) adds x as a single item, so appending a list creates a nested list.
A string is an iterable of characters, so extend("abc") adds a, b, and c. Use append("abc") or extend(["abc"]) to add the whole word.
Yes for lists: both change the list in place and accept any iterable. lst = lst + other is different because it creates a new list and needs a list on the right.
Only the keys are added, because iterating a dict gives its keys. Pass d.values() for the values or d.items() for (key, value) pairs.
Assign to an empty slice at position 0: lst[0:0] = new_items. extend() always adds at the end.

Next: list.index()

Return the position of the first item equal to a value.

index() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful