Write Python program to demonstrate check if list are identical


Topic: Write Python program to demonstrate check if list are identical

Solution

test_list1 = [1, 2, 4, 3, 5] 
test_list2 = [1, 2, 4, 3, 5] 
print ("The first list is : " + str(test_list1)) 
print ("The second list is : " + str(test_list2)) 
test_list1.sort() 
test_list2.sort() 
if test_list1 == test_list2: 
    print ("The lists are identical") 
else : 
    print ("The lists are not identical") 



List all Python Programs