How to Merge Two Lists in Python
If you want to combine two Python lists into one list, there are a few simple ways to do it.
On this page, you will learn:
- How to combine two lists into one list
- When to create a new list and when to change an existing list
- How to avoid common beginner mistakes when merging lists
Quick answer
list1 = [1, 2, 3]
list2 = [4, 5, 6]
merged = list1 + list2
print(merged)
Output:
[1, 2, 3, 4, 5, 6]
Use + when you want a new list that contains all items from both lists.
What this page helps you do
- Combine two lists into one list
- Choose between creating a new list or changing an existing list
- Avoid common beginner mistakes when merging lists
Method 1: Use + to create a new list
This is the clearest method for most beginners.
- Best for simple cases
- Returns a new list
- Does not change the original lists
- Works when both values are lists
Example:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
merged = list1 + list2
print("list1:", list1)
print("list2:", list2)
print("merged:", merged)
Output:
list1: [1, 2, 3]
list2: [4, 5, 6]
merged: [1, 2, 3, 4, 5, 6]
Why use +?
+ creates a brand new list.
The original lists stay the same.
This is useful when you want to keep list1 and list2 unchanged.
If you are still learning how lists work, this is usually the best method to start with. For a broader introduction, see Python lists explained for beginners.
Method 2: Use extend() to add items to an existing list
Use extend() when you want to add all items from one list into another list.
- Adds all items from the second list into the first list
- Changes the original list
- Useful when you want to keep one list and add to it
Example:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list1.extend(list2)
print(list1)
print(list2)
Output:
[1, 2, 3, 4, 5, 6]
[4, 5, 6]
What changed here?
After list1.extend(list2), list1 is modified.
list2 stays the same.
If you want to learn more about this method, see the Python list extend() method.
Method 3: Use unpacking with *
Another way to merge lists is to use unpacking.
Syntax:
[*list1, *list2]
- Creates a new list
- Helpful when combining more than two lists
Example:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
merged = [*list1, *list2]
print(merged)
Output:
[1, 2, 3, 4, 5, 6]
This is especially useful when merging several lists:
a = [1, 2]
b = [3, 4]
c = [5, 6]
merged = [*a, *b, *c]
print(merged)
Output:
[1, 2, 3, 4, 5, 6]
When to use each method
Choose the method based on what you want to happen:
- Use
+for the clearest beginner-friendly solution - Use
extend()when you want to modify the first list - Use unpacking when combining several lists in one line
A simple rule:
- Want a new list? Use
+or unpacking. - Want to change an existing list? Use
extend().
If you need to keep the original list before changing it, you may want to copy a list in Python first.
Important detail: nested list vs merged list
This is one of the most common list mistakes for beginners.
append(list2) does not merge the lists
append() adds the whole second list as one single item.
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list1.append(list2)
print(list1)
Output:
[1, 2, 3, [4, 5, 6]]
Notice that list2 became a nested list inside list1.
extend(list2) merges the items
extend() adds each item from list2 one by one.
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list1.extend(list2)
print(list1)
Output:
[1, 2, 3, 4, 5, 6]
Quick comparison
list1 = [1, 2]
list2 = [3, 4]
a = list1.copy()
a.append(list2)
b = list1.copy()
b.extend(list2)
print("append:", a)
print("extend:", b)
Output:
append: [1, 2, [3, 4]]
extend: [1, 2, 3, 4]
To learn more, compare the Python list append() method with the Python list extend() method.
Common mistakes
Here are some common reasons merging lists does not work as expected.
Using append() instead of extend()
Problem:
list1 = [1, 2]
list2 = [3, 4]
list1.append(list2)
print(list1)
Output:
[1, 2, [3, 4]]
Fix: use extend() if you want to add the items individually.
list1 = [1, 2]
list2 = [3, 4]
list1.extend(list2)
print(list1)
Expecting extend() to return a new list
This is a very common mistake.
Wrong:
list1 = [1, 2]
list2 = [3, 4]
merged = list1.extend(list2)
print(merged)
Output:
None
Why? Because extend() changes the list in place and returns None.
Correct:
list1 = [1, 2]
list2 = [3, 4]
list1.extend(list2)
print(list1)
Trying to merge a list with a non-list value
+ works when both values are lists.
Wrong:
list1 = [1, 2, 3]
value = 4
merged = list1 + value
This causes an error because value is not a list.
Correct:
list1 = [1, 2, 3]
value = 4
merged = list1 + [value]
print(merged)
Output:
[1, 2, 3, 4]
If you only want to add one item, see how to add an item to a list in Python.
Forgetting that + creates a new list
This does not change list1:
list1 = [1, 2]
list2 = [3, 4]
list1 + list2
print(list1)
Output:
[1, 2]
To keep the merged result, assign it to a variable:
list1 = [1, 2]
list2 = [3, 4]
merged = list1 + list2
print(merged)
Debugging tips
If your result is not what you expected, print the values and types:
print(list1)
print(list2)
print(type(list1))
print(type(list2))
print(merged)
These checks help you see:
- Whether your variables are really lists
- Whether one of the lists changed
- Whether
mergedcontains the result you expected
FAQ
What is the easiest way to merge two lists in Python?
Use list1 + list2 if you want a simple new list.
What is the difference between append() and extend()?
append() adds one item.extend() adds each item from another iterable.
Does extend() return a new list?
No. It changes the existing list and returns None.
Can I merge more than two lists?
Yes. You can use + multiple times or use unpacking like [*a, *b, *c].