Membership testing on set of pairs, how do i make the order of element in pairs irrelevant?

Viewed 643

Here is what I want to do:

m1 = (a,b)
m2 = (c,d)
bad_combos = set()
bad_combos.add((m1,m2)) #((a,b),(c,d))
... #adding many other elements in the set

#when i do this:
if (m2,m1) in bad_combos:
    print("Found")
else:
    print("Not Found")

#the result is always "Not Found"

Is there a way that I can make the order of elements in a pair irrelevant so when O do the membership testing:

bad_combos.add((m3,m4))

if (m4,m3) in bad_combos:

   #This will return True?

Any Idea will be greatly appreciated! Thanks in Advance!

2 Answers
Related