Simple Ways To Merge Two Lists in Python Without Overcomplicating It

Advertisement

Jun 04, 2025 By Tessa Rodriguez

Working with lists in Python is pretty common. Whether pulling data from APIs, combining inputs from different users, or just reorganizing things in a script, you'll eventually need to merge two lists. The idea is simple: take items from two lists and put them into one. But being flexible, Python gives you many ways to do it. Some are fast and clean, others give you more control. This article breaks down the main methods to merge lists, explains what each does, and when you might pick one over the other. No fluff—just practical stuff that helps you write better Python.

How To Merge Two Lists in Python?

Using the + Operator

This is probably the first method most people come across. You just use the + symbol to combine two lists.

list1 = [1, 2, 3]

list2 = [4, 5, 6]

merged = list1 + list2

print(merged) # [1, 2, 3, 4, 5, 6]

The original lists haven't changed. A new list is returned, so it's safe if you don't want to mess with your original data.

Using .extend() Method

The extend() method is used when you want to add all items from one list to another. Unlike +, it modifies the list in place.

list1 = [1, 2, 3]

list2 = [4, 5, 6]

list1.extend(list2)

print(list1) # [1, 2, 3, 4, 5, 6]

This is memory-efficient since it doesn’t make a new list but changes the first list. Use this if you don’t need to keep the original version.

Using * Unpacking

This method unpacks the elements of each list into a new one using the * operator inside square brackets.

list1 = [1, 2, 3]

list2 = [4, 5, 6]

merged = [*list1, *list2]

print(merged) # [1, 2, 3, 4, 5, 6]

It’s concise and clean. Good for cases where you want readability and a new list without touching the originals.

Using itertools.chain()

Itertools.chain() from the itertools module is useful for longer or more complex merges. It's efficient and lazy—it creates an iterator that only evaluates items as needed.

from itertools import chain

list1 = [1, 2, 3]

list2 = [4, 5, 6]

merged = list(chain(list1, list2))

print(merged) # [1, 2, 3, 4, 5, 6]

Best if you're dealing with large data and want to save memory. It’s more advanced, but worth knowing.

Using a Loop

This is the more manual way. You just loop through the second list and add each item to the first.

list1 = [1, 2, 3]

list2 = [4, 5, 6]

for item in list2:

list1.append(item)

print(list1) # [1, 2, 3, 4, 5, 6]

It's not fancy, but it works. If you're doing more than merging—like filtering or modifying items—a loop gives you more control.

Using List Comprehension

This method gives you a new list using a single expression. It’s great when you want to do something extra while merging.

list1 = [1, 2, 3]

list2 = [4, 5, 6]

merged = [item for item in list1] + [item for item in list2]

print(merged) # [1, 2, 3, 4, 5, 6]

You can also add logic:

merged = [item for item in list1 + list2 if item % 2 == 0]

print(merged) # [2, 4, 6]

Good when you want to filter or tweak while merging.

Using sum()

This trick is not always recommended, but it's still an option. You can "sum" a list of lists using sum() with an empty list as the starting point.

lists = [[1, 2], [3, 4], [5, 6]]

merged = sum(lists, [])

print(merged) # [1, 2, 3, 4, 5, 6]

For just two lists, it’s overkill:

merged = sum([[1, 2, 3], [4, 5, 6]], [])

It's not the most efficient for large lists but works when merging many small ones.

Using numpy.concatenate() (if you're working with numbers)

This method is fast and straightforward if you're doing numerical work and using NumPy.

import numpy as np

list1 = np.array([1, 2, 3])

list2 = np.array([4, 5, 6])

merged = np.concatenate((list1, list2))

print(merged) # [1 2 3 4 5 6]

This returns a NumPy array, not a regular Python list. It’s useful if you’re doing number crunching and performance matters.

Using functools.reduce()

The reduce() function from the functools module can merge lists by repeatedly applying a function. It's usually used for calculations, but you can apply it to list merging too. When you have many lists and want to join them into one, reduce() does the job cleanly.

from functools import reduce

lists = [[1, 2], [3, 4], [5, 6]]

merged = reduce(lambda x, y: x + y, lists)

print(merged) # [1, 2, 3, 4, 5, 6]

It’s useful when you’re working with many lists and prefer a functional approach.

Using operator.iconcat()

iconcat() is a function from the operator module that works like += for lists. It modifies the first list and adds items from the second. It's faster than + because it avoids making a copy.

import operator

list1 = [1, 2, 3]

list2 = [4, 5, 6]

operator.iconcat(list1, list2)

print(list1) # [1, 2, 3, 4, 5, 6]

Use this if you already use the operator module or need fast in-place merging without .extend().

Conclusion

Python gives you many ways to merge lists. If you want something quick and clean, use + or unpacking. Extend () or itertools.chain() if you care about memory or performance. For special cases, like working with numbers or wanting to filter on the fly, try NumPy or list comprehensions. None of these methods are wrong—they just serve different needs. Choose based on what you're doing, whether it's speed, clarity, or flexibility. Once you've tried them a few times, you'll get a feel for which fits best in your workflow. Python's simplicity is in giving you the tools and letting you pick how you want to work.

Advertisement

You May Like

Top

Understanding How SSH and Telnet Differ in Cyber Security

Learn the difference between SSH and Telnet in cyber security. This article explains how these two protocols work, their security implications, and why SSH is preferred today

Jul 15, 2025
Read
Top

How Nvidia NeMo Guardrails Addresses Trust Concerns with AI Bots

Nvidia NeMo Guardrails enhances AI chatbot safety by blocking bias, enforcing rules, and building user trust through control

Jun 06, 2025
Read
Top

Choosing the Right Solution for Your Data: Data Lake or Data Warehouse

Wondering whether a data lake or data warehouse fits your needs? This guide explains the differences, benefits, and best use cases to help you pick the right data storage solution

Jul 22, 2025
Read
Top

Quantum Meets AI: IonQ’s Path to Smarter Applications

How IonQ advances AI capabilities with quantum-enhanced applications, combining stable trapped-ion technology and machine learning to solve complex real-world problems efficiently

Aug 07, 2025
Read
Top

What It Takes to Build a Large Language Model for Code

Curious how LLMs learn to write and understand code? From setting a goal to cleaning datasets and training with intent, here’s how coding models actually come together

Jun 01, 2025
Read
Top

Boost Productivity: How to Use ChatGPT for Google Sheets in Everyday Tasks

How to use ChatGPT for Google Sheets to automate tasks, generate formulas, and clean data without complex coding or add-ons

May 31, 2025
Read
Top

Mastering Python Exit Commands: quit(), exit(), sys.exit(), and os._exit()

Explore the different Python exit commands including quit(), exit(), sys.exit(), and os._exit(), and learn when to use each method to terminate your program effectively

May 15, 2025
Read
Top

Google's AI-Powered Search: The Key to Retaining Samsung's Partnership

Google risks losing Samsung to Bing if it fails to enhance AI-powered mobile search and deliver smarter, better, faster results

Jun 02, 2025
Read
Top

Which Language Model Works Best? A Look at LLMs and BERT

How LLMs and BERT handle language tasks like sentiment analysis, content generation, and question answering. Learn where each model fits in modern language model applications

May 19, 2025
Read
Top

Formula One Teams Are Now Designing Race Cars with AI—Here’s How

Can AI really help a Formula One team build faster, smarter cars? With real-time data crunching, simulation, and design automation, teams are transforming racing—long before the track lights go green

Jul 23, 2025
Read
Top

How Different Industries Apply Generative AI to Innovate and Thrive

Learn how the healthcare, marketing, finance, and logistics industries apply generative AI to achieve their business goals

May 29, 2025
Read
Top

Writer Launches AI Agent Platform for Businesses

Writer unveils a new AI platform empowering businesses to build and deploy intelligent, task-based agents.

Jun 04, 2025
Read