Python program to merge / concatenate two lists

Hello everyone, welcome back to programminginpython.com. Here in this post am going to tell you how to concatenate / merge lists.

You can watch this video on Youtube here

Program on Github

Add, merge or concatenate lists – Code Visualization

Task:

To merge / add / concatenate lists.

Approach:

  • Read input number asking for length of the list using input() or raw_input().
  • Initialise an empty list lst = [].
  • Read each number using a for loop.
  • In the for loop append each number to the list.
  • Repeat the above 4 points for the second list lst2[] as well.
  • Now add / merge / concatenate two lists lst + lst2
  • Print the resultant list of the above operation.

Program on Github

Program:

Output:

Concatenate lists in Python - programminginpython.com
Concatenate lists in Python – programminginpython.com

Program on Github

Leave a Reply