I've a dictionary with a (x,y) key, where (x,y) means the same as (y,x), How should I do this ? I can do:
(x,y)
(y,x)
>>> d = {(1,2): "foo"} >>> i = d.get(2,1) >>> if i ...
If I have a dict such as:
foo = {('foo', 45):5, ('bar', 34):3}
if 'foo' in foo: #should be true pass if 45 ...
I hope this hasn't been asked before but it's hard for me to put into words what it is I'm trying to do! It might be easier if I explain my input, ...
Let's say I have names as a list of tuples that contain name tuples in arbitrary order:
names
names = [(1,"Alice"), (2,"Bob")]
genders
I am trying to build a function in python that yields values of two dictionaries IF a particular value from dict1 matches a particular value of dict2. My function looks like ...
dict1
dict2