Write a python program to check whether two lists are circularly identical


This program compares two lists, list1 and list2, and list1 and list3 using the in operator. First, it converts the elements of both lists to strings using the map() function and the str() function. Then, it uses the join() function to join the elements of the lists together into a single string.

Then it uses the in operator to check if the elements of list2 are in the elements of list1 multiplied by 2. And it does the same for list3. If the elements of list2 are present in the elements of list1 multiplied by 2, it returns True, otherwise, False. Then it prints the result of the comparison between list1 and list2 and list1 and list3.

Source Code

list1 = [8, 8, 12, 12, 8]
list2 = [8, 8, 8, 12, 12]
list3 = [1, 8, 8, 12, 12]
 
print("Compare List1 and List2 : ",' '.join(map(str, list2)) in ' '.join(map(str, list1 * 2)))
print("Compare List1 and List3 : ",' '.join(map(str, list3)) in ' '.join(map(str, list1 * 2)))
 

Output

Compare List1 and List2 :  True
Compare List1 and List3 :  False

Example Programs