How to Combine Two Lists in Python

What you’ll build or solve

You’ll combine two Python lists into one list using the best method for your situation.

When this approach works best

Combining two lists works well when you:

  • Merge two result sets, like items from two API calls or two files.
  • Add new items onto an existing list, like appending a new page of search results.
  • Pair related data, like names and scores, into tuples for processing.

Skip these approaches when you must keep items unique. In that case, remove duplicates after combining, or use a set if order does not matter.

Prerequisites

  • Python 3 installed
  • You know what a list is

Step-by-step instructions

1) Combine lists by creating a new list

Use + when you want a new list and you do not want to change the original lists.

a= [1,2,3]
b= [4,5]

combined=a+b
print(combined)

What to look for: a and b stay the same. combined is a new list.


2) Combine lists in place with .extend()

Use .extend() when you want to add items to an existing list.

a= [1,2,3]
b= [4,5]

a.extend(b)
print(a)

What to look for: .extend() modifies a directly. It does not return the combined list.


3) Combine lists by pairing items with zip()

Use zip() when you want to combine two lists item-by-item.

names= ["Amina","Luka","Noor"]
scores= [42,38,50]

pairs=list(zip(names,scores))
print(pairs)

What to look for: zip() stops at the shortest list. Extra items in the longer list are ignored.


Examples you can copy

Example 1: Combine two lists of strings

fruits= ["apple","banana"]
more_fruits= ["pear","mango"]

all_fruits=fruits+more_fruits
print(all_fruits)

Example 2: Add new results onto an existing list

results= ["p1","p2"]
new_page= ["p3","p4"]

results.extend(new_page)
print(results)

Example 3: Combine many lists into one

parts= [[1,2], [3], [4,5]]
combined= []

forpinparts:
combined.extend(p)

print(combined)

Example 4: Pair items and compute something

names= ["Amina","Luka","Noor"]
scores= [42,38,50]

forname,scoreinzip(names,scores):
print(name,score>=40)

Example 5: Keep leftovers when pairing uneven lists

If you need to keep extra items, use itertools.zip_longest.

fromitertoolsimportzip_longest

names= ["Amina","Luka","Noor"]
scores= [42,38]

pairs=list(zip_longest(names,scores,fillvalue=None))
print(pairs)

Common mistakes and how to fix them

Mistake 1: Assigning the result of .extend()

What you might do:

a= [1,2]
b= [3,4]

combined=a.extend(b)
print(combined)

Why it breaks: .extend() returns None because it modifies the list in place.

Correct approach:

a= [1,2]
b= [3,4]

a.extend(b)
combined=a

print(combined)

Or create a new list:

combined=a+b

Mistake 2: Expecting zip() to keep items from the longer list

What you might do:

names= ["Amina","Luka","Noor"]
scores= [42]

pairs=list(zip(names,scores))
print(pairs)

Why it breaks: zip() stops at the shortest list, so extra names are dropped.

Correct approach:

fromitertoolsimportzip_longest

names= ["Amina","Luka","Noor"]
scores= [42]

pairs=list(zip_longest(names,scores,fillvalue=None))
print(pairs)

Mistake 3: Using append() instead of extend()

What you might do:

a= [1,2]
b= [3,4]

a.append(b)
print(a)

Why it breaks: append() adds the entire list as a single element, creating a nested list.

Correct approach:

a= [1,2]
b= [3,4]

a.extend(b)
print(a)

Troubleshooting

If you see TypeError when using +, confirm both values are lists. a + b will not work if b is a tuple or a string.

If your list becomes nested, you probably used append() with a list. Use extend() instead.

If you get None after combining, you assigned the result of .extend(). Call it without assignment.

If items are missing after zip(), one list is longer. Use zip_longest() if you need to keep leftovers.


Quick recap

  • Use a + b to create a new combined list.
  • Use a.extend(b) to add items to an existing list.
  • Use zip(a, b) to combine item-by-item.
  • Use zip_longest() when list lengths don’t match, and you need leftovers.
  • Use extend(), not append(), to avoid nested lists.