In this post, we will learn how to write a program to print if two tuples are the same in any order or not.
Implementation:
t=eval(input("enter a tuple"))
t1=eval(input("enter a tuple"))
count=len(t)
samecount=0
found=False
for e in t:
for a in t1:
if e==a:
found=True
samecount+=1
if found==False:
break
if samecount==count:
print("both are same")
else:
print("not same")
Output:
enter a tuple 1,2,3,4,5,6,7,8
enter a tuple 8,7,6,5,4,3,2,1
both are same
Happy Coding!
Follow us on Instagram @programmersdoor
Join us on Telegram @programmersdoor
Please write comments if you find any bug in the above code/algorithm, or find other ways to solve the same problem.
Follow Programmers Door for more.
Comentarios