I have formed a dictionary with 2 keys assigning to a single dictionary value, for example:
my_dict[x, y] = ...
my_dict[a, u] = ...
Now how would i be able to use the has_key() method for 2 key variables, x and y like such:
if my_dict.has_key(x,y) == True:
Do Something
else:
Do something else
d is a matrix, that uses pdict values that i call from a variable f and g, but all you need to know is that they are variable names x,y being used as key values in pdict.
Since
dict.has_key()has been deprecated for a long time now, you should use theinoperator instead:Note that your dictionary does not have “two keys”. It probably uses a
tupleof two elements as a key, but that tuple is a single object.