Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
2 like 0 dislike
645 views
in Practice & Doubts by Goeduhub's Expert (2.2k points)
Write a python program to check whether two lists are circularly identical.

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 360/- || For International Students- $9.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

3.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon
    More Courses

5 Answers

0 like 1 dislike
by (375 points)
Answer ----

list1= [5,10,0,0,10]

list2= [5,10,10,0,0]

list3= [5,10,5,0,0]

print('compare list1 and list2')

print(' '.join(map(str, list 2)) in ' '.join(map(str, list1 *  2)

print('compare list1 and list3')

print(' '.join(map(str, list3)) in ' '.join(map(str, list1 * 3)
0 like 0 dislike
by (385 points)

# python program to check if two 

# lists are circularly identical

def circularly_identical(lst1, lst2): 

return(' '.join(map(str, lst2)) in ' '.join(map(str, lst1 * 2))) 

lst1 = [10, 10, 0, 0, 10] 

lst2 = [10, 10, 10, 0, 0] 

lst3 = [1, 10, 10, 0, 0] 

if(circularly_identical(lst1, lst2)): 

print"Yes"

else: 

print"No"

if(circularly_identical(lst2, lst3)): 

print "Yes"

else: 

print"No"

0 like 0 dislike
by (442 points)
l1 = [10, 0, 0, 10, 5]

l2 = [10, 5, 10, 0, 0]

l3 = [5, 10, 10, 0, 0]

for i in range(len(l2)):
    l1.append(l1[i])

s1 = str(l1)
s2 = str(l2)
s3 = str(l3)

x = s2[1:len(s2) - 1]
y = s3[1:len(s3) - 1]

print("For l1 and l2 ", x in s1)

print("For l1 and l3 ", y in s1)

#For l1 and l2  True
#For l1 and l3  False

1 like 0 dislike
by (437 points)
list1 = [1, 0, 1, 0, 1] 
list2 = [0, 1, 0, 1, 0]

if(' '.join(map(str, list1)) in ' '.join(map(str, list2 * 2))): 
    print ("Lists are circularly identical") 
else: 
    print ("Lists are not circularly identical")
1 like 0 dislike
by (563 points)
edited by
#python 3

#python program to check whether 2 lists are circularly identical or not.

(Input from user)

A=list()

n=int(input("Enter the size of the First List ::"))

print("Enter the Element of First List ::")

for i in range(int(n)):

   k=int(input(""))

   A.append(k)

B=list()

n1=int(input("Enter the size of the Second List ::"))

print("Enter the Element of the Second List ::")

for i in range(int(n1)):

   k=int(input(""))

   B.append(k)

print("Compare First List and Second List ::>")

print(' '.join(map(str, B)) in ' '.join(map(str, A * 2)))

Output:
Enter the size of the First List ::5

Enter the Element of First List ::

1

2

3

4

5

Enter the size of the Second List ::5

Enter the Element of the Second List ::

2

3

4

5

1

Compare First List and Second List ::>

True
by Goeduhub's Expert (2.2k points)
Not Correct...kindly retry

3.3k questions

7.1k answers

394 comments

4.6k users

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...