How to Join Lists in Python: Concatenation Techniques

Explore different methods for joining or concatenating lists in Python. Learn how to use the + operator to combine two or more lists into a single list. Discover practical examples to effectively merge lists and manage data in your Python applications.



Python - Join Lists

Join Two Lists

There are several ways to join, or concatenate, two or more lists in Python. One of the easiest methods is by using the + operator.

Example

Join two lists:


list1 = ["dog", "cat", "bird"]
list2 = [4, 5, 6]
    
list3 = list1 + list2
print(list3)
Output

['dog', 'cat', 'bird', 4, 5, 6]

Another way to join two lists is by appending all the items from list2 into list1 one by one:

Example

Example

Append list2 into list1:


list1 = ["dog", "cat", "bird"]
list2 = [4, 5, 6]
    
for x in list2:
     list1.append(x)
    
print(list1)
Output

['dog', 'cat', 'bird', 4, 5, 6]

Alternatively, you can use the extend() method, which adds elements from one list to another:

Example

Use the extend() method to add list2 to the end of list1:


list1 = ["dog", "cat", "bird"]
list2 = [4, 5, 6]
    
list1.extend(list2)
print(list1)
Output

['dog', 'cat', 'bird', 4, 5, 6]