Python List extend() Method

list.extend() adds items from another iterable to the end of a list.

It changes the original list in place, which means it updates the same list instead of creating a new one. This method is useful when you want to add multiple values at once.

Quick example #

numbers = [1, 2]
more_numbers = [3, 4]

numbers.extend(more_numbers)
print(numbers)
# [1, 2, 3, 4]

Use extend() when you want to add each item from another iterable into the same list.

What list.extend() does #

extend():

  • Adds items from another iterable to the end of a list
  • Changes the original list in place
  • Does not create a new list
  • Returns None

This is an important point: extend() updates the list you already have.

Basic syntax #

list_name.extend(iterable)

The argument must be an iterable. An iterable is something Python can loop through one item at a time.

Common iterables include:

  • list
  • tuple
  • set
  • string
  • range

Simple example with another list #

Here is the most common use of extend():

fruits = ["apple", "banana"]
more_fruits = ["orange", "grape"]

fruits.extend(more_fruits)

print(fruits)
# ['apple', 'banana', 'orange', 'grape']

What happens here:

  • fruits starts with two items
  • more_fruits has two more items
  • extend() adds each item from more_fruits to fruits

After the method runs, fruits contains all four items.

If you are new to lists, see Python lists explained for beginners and creating a list in Python.

extend() vs append() #

extend() and append() are often confused.

extend() adds each item from the iterable #

numbers = [1, 2]
numbers.extend([3, 4])

print(numbers)
# [1, 2, 3, 4]

append() adds the whole object as one item #

numbers = [1, 2]
numbers.append([3, 4])

print(numbers)
# [1, 2, [3, 4]]

Use:

  • extend() to combine values
  • append() to add one item

If you want a full comparison, see Python list append() method and how to add an item to a list in Python.

Using extend() with different iterables #

extend() works with more than just lists.

Extend with a tuple #

values = [1, 2]
values.extend((3, 4))

print(values)
# [1, 2, 3, 4]

Each tuple item is added to the list.

Extend with a string #

letters = ["a"]
letters.extend("bc")

print(letters)
# ['a', 'b', 'c']

A string is iterable, so each character is added separately.

Extend with a range #

numbers = [0]
numbers.extend(range(1, 4))

print(numbers)
# [0, 1, 2, 3]

range(1, 4) produces 1, 2, and 3.

Extend with a set #

items = [1, 2]
items.extend({3, 4})

print(items)

A set works too, but the order may not be predictable.

Important return value rule #

extend() returns None.

That means this is wrong:

numbers = [1, 2]
result = numbers.extend([3, 4])

print(result)
# None

And this is also a common mistake:

numbers = [1, 2]
numbers = numbers.extend([3, 4])

print(numbers)
# None

The correct way is:

numbers = [1, 2]
numbers.extend([3, 4])

print(numbers)
# [1, 2, 3, 4]

Call extend() first, then use the original list.

Common beginner mistakes #

Here are some common problems beginners run into with extend().

1. Expecting extend() to return a new list #

numbers = [1, 2]
new_numbers = numbers.extend([3, 4])

print(new_numbers)
# None

Fix: use the original list after calling extend().

2. Using append() when extend() is needed #

numbers = [1, 2]
numbers.append([3, 4])

print(numbers)
# [1, 2, [3, 4]]

If you wanted [1, 2, 3, 4], use extend() instead.

3. Passing a string and being surprised by separate characters #

words = ["hello"]
words.extend("world")

print(words)
# ['hello', 'w', 'o', 'r', 'l', 'd']

If you want "world" as one item, use append():

words = ["hello"]
words.append("world")

print(words)
# ['hello', 'world']

4. Trying to extend with a non-iterable like an integer #

numbers = [1, 2]
numbers.extend(5)

This causes an error because 5 is not iterable.

You will get a TypeError. See TypeError: int object is not iterable for help fixing that error.

Useful checks while debugging:

print(my_list)
print(type(values))
print(result))
help(list.extend)

Note: print(result)) has an extra ) and would cause a syntax error. The correct version is print(result).

Correct debugging example:

my_list = [1, 2]
values = [3, 4]

my_list.extend(values)

result = None
print(my_list)
print(type(values))
print(result)
help(list.extend)

When to use extend() #

Use extend() when you want to:

  • Merge two lists into one existing list
  • Add multiple values at once
  • Build a list step by step without creating a new list

For example:

all_scores = [90, 85]
new_scores = [88, 92]

all_scores.extend(new_scores)

print(all_scores)
# [90, 85, 88, 92]

If you need to add just one value, append() is usually better. If you need to add an item at a specific position, see Python list insert() method.

FAQ #

Does list.extend() return a new list? #

No. It changes the original list and returns None.

What is the difference between extend() and append()? #

extend() adds each item from an iterable. append() adds one item as a single element.

Can I use extend() with a string? #

Yes, but each character is added separately.

Can I use extend() with a tuple? #

Yes. Each tuple item is added to the list.

What happens if I pass an integer to extend()? #

You get a TypeError because an integer is not iterable.

See also #

If you are choosing between list methods, the next useful step is learning when to use append(), when to use insert(), and when it makes more sense to create a new merged list instead of changing the original one.

Press Esc to close