>>> foo = {('foo', 45): 5, ('bar', 34): 3} >>> any(t1 == "foo" for (t1, t2) in foo) True >>> any(t2 == 45 for (t1, t2) in foo) True
If you don't know where the value is located, you can simply check the whole pair:
>>> any(45 in pair for pair in foo) True
You can also use a generator ( flatten ):
>>> 45 in flatten(foo) True
However, perhaps the best idea is to collect your data so that you can check this type of slope O (1) times (set? Reorganized dictionary?)
source share