How to Add an Item to a List in Python
If you want to add values to a Python list, the method you use depends on what result you want.
This page shows the simplest ways to:
- Add one item to the end of a list
- Add multiple items to a list
- Add an item at a specific position
- Understand when to use
append(),extend(), orinsert()
Quick answer
numbers = [1, 2, 3]
numbers.append(4)
print(numbers)
# [1, 2, 3, 4]
Use append() to add one item to the end of a list.
What this page helps you do
- Add one item to the end of a list
- Add multiple items to a list
- Add an item at a specific position
- Understand when to use
append(),extend(), orinsert()
Use append() to add one item
append() adds one item to the end of a list.
It changes the original list. It does not create a new list.
fruits = ["apple", "banana"]
fruits.append("orange")
print(fruits)
# ['apple', 'banana', 'orange']
What to notice
append()adds one value- The new item goes at the end
- The original list is modified
This is the best choice when you want to add a single value.
If you want a full method reference, see Python list append() method.
Use extend() to add multiple items
extend() adds each item from another iterable to the list.
An iterable is something Python can loop through, such as a list or tuple.
numbers = [1, 2, 3]
numbers.extend([4, 5, 6])
print(numbers)
# [1, 2, 3, 4, 5, 6]
Why not use append() here?
If you use append() with a list, Python adds the whole list as one item.
numbers = [1, 2, 3]
numbers.append([4, 5])
print(numbers)
# [1, 2, 3, [4, 5]]
This creates a nested list.
If you want a flat list, use extend() instead:
numbers = [1, 2, 3]
numbers.extend([4, 5])
print(numbers)
# [1, 2, 3, 4, 5]
Use extend() when you want to add many values at once.
You can learn more on the Python list extend() method page. If your goal is combining two lists, see how to merge two lists in Python.
Use insert() to add an item at a specific index
insert(index, value) adds an item before the given index.
This is useful when order matters.
letters = ["a", "c", "d"]
letters.insert(1, "b")
print(letters)
# ['a', 'b', 'c', 'd']
How it works
insert(0, item)adds at the beginninginsert(1, item)adds before index1- Items after that position are shifted to the right
Example:
colors = ["red", "blue"]
colors.insert(0, "green")
print(colors)
# ['green', 'red', 'blue']
Use insert() when you need to place an item in a specific position.
For more details, see Python list insert() method.
Choose the right method
Pick the method based on the result you want:
- Use
append()for one item at the end - Use
extend()for many items - Use
insert()for a specific position
Here is a quick comparison:
items = [1, 2, 3]
items.append(4)
print(items)
# [1, 2, 3, 4]
items.extend([5, 6])
print(items)
# [1, 2, 3, 4, 5, 6]
items.insert(0, 0)
print(items)
# [0, 1, 2, 3, 4, 5, 6]
If lists are still new to you, it may help to read Python lists explained for beginners.
Common beginner mistakes
Here are some common problems and how to spot them.
Using append() when you meant to add items from another list
Problem:
numbers = [1, 2, 3]
numbers.append([4, 5])
print(numbers)
# [1, 2, 3, [4, 5]]
Why it happens:
append()adds its argument as one item- If that argument is a list, the list becomes a single element
Fix:
numbers = [1, 2, 3]
numbers.extend([4, 5])
print(numbers)
# [1, 2, 3, 4, 5]
Expecting append() to return the new list
Problem:
my_list = [1, 2, 3]
my_list = my_list.append(4)
print(my_list)
# None
Why it happens:
- List methods like
append()usually modify the list in place append()returnsNone
Fix:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
# [1, 2, 3, 4]
Using the wrong index with insert()
Problem:
names = ["Ana", "Cara"]
names.insert(1, "Ben")
print(names)
# ['Ana', 'Ben', 'Cara']
This code is correct, but beginners sometimes expect index 1 to mean "after everything." It means "before the item currently at index 1."
If you want to add at the end, use append() instead.
Confusing a nested list with a flat list
Compare these two results:
a = [1, 2]
a.append([3, 4])
print(a)
# [1, 2, [3, 4]]
b = [1, 2]
b.extend([3, 4])
print(b)
# [1, 2, 3, 4]
The first list contains a list inside it. The second is a flat list.
Quick debugging checks
If your list is not changing the way you expected, these quick checks can help:
print(my_list)
print(type(my_list))
print(len(my_list))
print(my_list[-1])
These show:
- the current list contents
- whether the variable is still a list
- how many items are in the list
- the last item in the list
FAQ
How do I add one item to a list in Python?
Use list.append(item). It adds the item to the end of the list.
How do I add multiple items to a list?
Use list.extend(iterable) to add each item from another list, tuple, or similar iterable.
How do I add an item at the beginning of a list?
Use list.insert(0, item). This puts the item at index 0.
Why did append() create a nested list?
append() adds its argument as one item. If that argument is a list, the whole list is added as a single element.
Does append() return a new list?
No. append() changes the original list and returns None.