Joining lists in Python is a common operation for merging multiple data sequences into a single, unified structure for easier processing. It is particularly useful for combining results from different functions, aggregating user inputs, or preparing data for iteration, sorting, or further transformations.
In this tutorial, you will learn to join lists in Python using 7 methods.

Prerequistes
- Python installed (install Python on Ubuntu, Windows, macOS, or Rocky Linux).
- Access to the command line.
How to Join Lists with Python
There are several ways to join Python lists, depending on whether you want to create a new list, modify an existing one, or merge multiple lists efficiently. Each option offers unique advantages, allowing you to choose the most suitable method based on your data structure and performance needs.
The sections below show multiple approaches to joining lists in Python, with examples that demonstrate their use. Run the examples either:
- In the interactive shell (directly in a terminal).
- Using a Python IDE.
- Or as a Python script, as done in this tutorial.
Method 1: append() in a loop
One way to join lists is to use the append() method within a loop. You start with an empty list, then iterate over each list you want to merge, and append each element individually.
This method provides full control over how elements are added, but it is not the most efficient option because each append() call handles only one element at a time. Use this method if you want to perform extra processing or checks before adding items to the final list.
Follow the steps below:
1. Create a new file. Use a text editor such as nano:
nano append.py
2. Paste the following code:
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8, 9]
result = []
for lst in (a, b, c):
for item in lst:
result.append(item)
print(result)
3. Save and exit the file.
4. Run the script:
python3 append.py

The result is a single flat list containing all elements in order.
Method 2: extend()
A more efficient in-place method is extend(). When you call list1.extend(list2), Python appends all items from list2 into list1. This does not create a new list, which is more memory-efficient for large lists. Use extend() to merge lists when you do not need to preserve the original lists separately.
Follow the steps below:
1. Create a new script:
nano extend.py
2. Paste the following code:
a = [1, 2, 3]
b = [4, 5, 6]
a.extend(b)
print(a)
3. Save and exit the editor.
4. Run the script:
python3 extend.py

The result is a list where all elements of the second list are added individually to the end of the first list.
Note: extend() modifies the original list. If you need to preserve a and b, use a + b or list unpacking instead.
Method 3: The + Operator
If you prefer a simple and readable syntax, use the + operator to concatenate lists. This method creates a new list that contains elements of both operands. Since it builds a fresh list, it is less memory-efficient than extend() for very large lists, but it is great for combining results without modifying the originals.
Follow the steps below:
1. Create a new file:
nano plus.py
2. Paste the following code:
a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
print(c)
3. Save and exit the file.
4. Run the file:
python3 plus.py

The result is a new list containing the elements of both lists in sequence.
Method 4: Unpacking with *
Python's unpacking operator (*) allows users to flatten multiple lists into a single list with very clean syntax. This method is especially useful when you want to combine more than two lists without repeatedly using the + operator.
Follow the steps below:
1. Create a new file:
nano asterisk.py
2. Paste the code below:
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8]
combined = [*a, *b, *c]
print(combined)
3. Save and exit the file.
4. Run the file:
python3 asterisk.py

The result is a new list that includes the unpacked elements of each iterable in the order they were provided.
Note: Although this method is readable and expressive, keep in mind that unpacking large lists creates a large single list in memory.
Method 5: List Comprehension
List comprehension is a built-in Python feature that makes it easy to construct new lists from existing ones. It offers the flexibility to include conditions or transform elements while you merge, and it is often preferred when readability and flexibility are important.
Follow the steps below:
1. Create a new file:
nano list_comprehension.py
2. Paste the following code:
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8]
combined = [x for lst in (a, b, c) for x in lst]
print(combined)
3. Save and exit the file.
4. Run the script:
python3 list_comprehension.py

The result is a new list constructed element by element, optionally applying conditions or transformations during the merge.
Method 6: itertools.chain()
The itertools.chain from the itertools module offers a memory-efficient and elegant solution for joining lists. It returns an iterator that yields elements from each iterable in sequence, without building an intermediate list until you explicitly convert it.
Use this approach when working with large datasets or when you need to process elements lazily without loading everything into memory at once.
Follow the steps below:
1. Create a new script:
nano itertools.py
2. Paste the code below:
import itertools
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8]
combined = list(itertools.chain(a, b, c))
print(combined)
3. Save and exit the file.
4. Run the file:
python3 itertools.py

The result is an iterator that yields all elements from the input iterables in order, producing a list only when explicitly converted.
Method 7: Interleaving with zip()
If you want to interleave elements from multiple lists (e.g., take one element from each list in turn), zip() combined with comprehension is the best choice. However, note that zip() stops when the shortest list is exhausted.
You can also use itertools.zip_longest (from itertools) if you want to continue until the longest list is exhausted, filling missing values with a placeholder.
Follow the steps below:
1. Create a new file:
nano interleaving.py
2. Paste the following code:
a = [1, 2, 3]
b = ['a', 'b', 'c']
c = [True, False, None]
interleaved = [item for trio in zip(a, b, c) for item in trio]
print(interleaved)
3. Save and exit the file.
4. Run the script:
python3 interleaving.py

The result is a flat list where elements from each list appear in alternating order.
Conclusion
This tutorial showed how to join lists in Python through several different methods that depend on your use case. Each method focuses on different things: memory usage, whether you want the original lists preserved, and whether you need to interleave or just concatenate. Mastering these methods allows you to choose the best one in any situation.
Next, see how to convert strings to floating-point numbers or how to reverse a list in Python.



