compare two list in python by R4R Team

program to compare two list-

print("Enter number in first list")
l1=list(map(int,input().split()))
print("Enter number in second list")
l2=list(map(int,input().split()))

print("List1 is",l1)
print("List2 is",l2)

if l1>l2:
print("list1 contain maximum number")
elif l2>l1:
print("List2 contain maximum number")
else:
print("No comparision exist")


output-

Enter number in first list
1 2 3 4
Enter number in second list
1 2 3
List1 is [1, 2, 3, 4]
List2 is [1, 2, 3]
List1 contain maximum number

Enter number in first list
8
Enter number in second list
4 3 2
List1 is [8]
List2 is [4, 3, 2]
List1 contain maximum number


-In this program, we comapre two list and try to find in which list the maximum number exist, and print that list which contain greator number.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!