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,

Output:

 

Click Here to Subscribe for more Articles / Tutorials like this.