How do I check if any 2 of n variables are equal in python. And is there a nice way to do it?
This is the situation
s = input()
D = int(input())
A, B, C = map( lambda x: D % int(x) , s.split())
if A == B == C: ? checks if all are equal
...
print(min(A, B, C))
Thanks alot :)
CodePudding user response:
I'm sorry I misread it. How about this one?
if len(set(a,b,c)) < 3
CodePudding user response:
For a N-way test:
from itertools import combinations
def multi_equals(ls):
for x,y in combinations(ls,2):
if x==y:
return True
else:
return False
a=1
b=2
c=3
d=2
multi_equals([a,b,c,d])
True
multi_equals([a,b,c])
False