In this article we will discuss different ways to Merge / Join two or more lists.

Suppose we have two lists i.e.

Now lets discuss how to merge contents of these list into a single list i.e.

Merging two lists using + operator

We can use + operator to merge two lists i.e.

It will return a new concatenated lists i.e.

list1 and list2 will remain same.

Merging two lists using list.extend()

If we want to extend any existing list by concatenating the contents of any other lists to it. Then we should use lists’ extend() method.

list.extend() makes a list longer by appending the elements of another list at the end.

Suppose we have two lists i.e.

Let’s extend list1 by adding the contents of list2 at the end of list1 i.e.

Now contents of list1 will be extended i.e.

Merging multiple lists using + operator

Suppose we have 3 lists i.e.

Now let’s merge all the three lists into a single list i.e.

New list’s contents will be,

Complete example is as follows,



Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.