Advertisement
Arcot

ch7 ex6 circularly identical

Jan 14th, 2022
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def circularly_identical(list1, list2):
  2.      
  3.     # doubling list
  4.     list3 = list1 * 2
  5.      
  6.     # traversal in twice of list1
  7.     for x in range(0, len(list1)):
  8.         z = 0
  9.          
  10.         # check if list2 == list1 curcularly
  11.         for y in range(x, x + len(list1)):
  12.             if list2[z]== list3[y]:
  13.                 z+= 1
  14.             else:
  15.                 break
  16.              
  17.         # if all n elements are same circularly
  18.         if z == len(list1):
  19.             return True
  20.      
  21.     return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement