'Python check for three way equality

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 :)



Solution 1:[1]

I'm sorry I misread it. How about this one?

if len(set((a,b,c))) < 3:
    ...

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ttrss
Solution 2 gimix