は、私が何をしたいです:ペアのメンバーシップテストは、どのようにペアの要素の順序を無関係にするのですか?ここ
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"
は、Oは、メンバーシップのテストを行うとき、私はペア内の要素の順序は無関係で作ることができる方法はあります:
bad_combos.add((m3,m4))
if (m4,m3) in bad_combos:
#This will return True?
任意のアイデア大いに感謝されます! ありがとうございました!
順序が重要でない場合は、 'tuple'(ペア)の代わりに' set'を使用することができます – Phydeaux