Home » programming » python » Python program to merge two list.

ABOUT SITE

  • learning code,doing coding is so interesting but sometimes we get confused to write a code,we get confused what actually the action of code is happening in a program So,don’t worry about all those things.in this website you will get code as well as its proper explanation what the code actually doing in the program,
  • so,the main motto of this site is to share knowledge to the people.

Python program to merge two list.

How to start:

  1. Take two list from from the user.
  2. Then , merge two list and show the result.

Source code:


a=[]
c=[]
n1=int(input("Enter number of elements:"))
for i in range(1,n1+1):
b=int(input("Enter element:"))
a.append(b)
n2=int(input("Enter number of elements:"))
for i in range(1,n2+1):
d=int(input("Enter element:"))
c.append(d)
n=a+c
new.sort()
print("Sorted list is:",n)

Output:

Explanation:

  1. User input number of element and element for two list .
  2. Program add two list and print result.

Leave a comment

Your email address will not be published. Required fields are marked *