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

How to Build a $10K/Month Faceless YouTube Channel Using AI

Discover the exact AI tools and strategies to build a faceless YouTube channel that earns $10K/month.

Jun 11, 2025
Read
Top

The Advantages and Disadvantages of AI in Cybersecurity: What You Need to Know

Know how AI transforms Cybersecurity with fast threat detection, reduced errors, and the risks of high costs and overdependence

Jun 06, 2025
Read
Top

Optimizing SetFit Inference Performance with Hugging Face and Intel Xeon

Achieve lightning-fast SetFit Inference on Intel Xeon processors with Hugging Face Optimum Intel. Discover how to reduce latency, optimize performance, and streamline deployment without compromising model accuracy

May 26, 2025
Read
Top

SmolAgents Gain Sight for Smarter Real-World Actions

Can small AI agents understand what they see? Discover how adding vision transforms SmolAgents from scripted tools into adaptable systems that respond to real-world environments

May 12, 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

Understanding the Role of ON in SQL Joins

Struggling to connect tables in SQL queries? Learn how the ON clause works with JOINs to accurately match and relate your data

May 17, 2025
Read
Top

Optimize Vision-Language Models With Human Preferences Using TRL Library

How can vision-language models learn to respond more like people want? Discover how TRL uses human preferences, reward models, and PPO to align VLM outputs with what actually feels helpful

Jun 11, 2025
Read
Top

Mastering f-strings in Python: Smart and Simple String Formatting

Get full control over Python outputs with this clear guide to mastering f-strings in Python. Learn formatting tricks, expressions, alignment, and more—all made simple

May 15, 2025
Read
Top

How H100 GPUs and DGX Cloud Simplify High-Performance AI Training

Speed up your deep learning projects with NVIDIA DGX Cloud. Easily train models with H100 GPUs on NVIDIA DGX Cloud for faster, scalable AI development

May 26, 2025
Read
Top

Serverless GPU Inference for Hugging Face Users: Fast, Scalable AI Deployment

How serverless GPU inference is transforming the way Hugging Face users deploy AI models. Learn how on-demand, GPU-powered APIs simplify scaling and cut down infrastructure costs

May 26, 2025
Read
Top

The Game-Changing Impact of Watsonx AI Bots in IBM Consulting's GenAI Efforts

Watsonx AI bots help IBM Consulting deliver faster, scalable, and ethical generative AI solutions across global client projects

Jun 18, 2025
Read
Top

Simple Ways To Merge Two Lists in Python Without Overcomplicating It

Looking for the best way to merge two lists in Python? This guide walks through ten practical methods with simple examples. Whether you're scripting or building something big, learn how to combine lists in Python without extra complexity

Jun 04, 2025
Read