I have a dictionary having tuple as its key and also tuple as its values. I need a way to access the values of dictionary based on its keys. For example:
d = {}
d = { (1, 2) : ('A', 'B'),(3, 4) : ('C', 'B') }
Now, first I need to check if keys (1, 2)
already exists in a dictionary.
Something like:
if d.has_key(1,2)
print d[1]
print d[2]
You can simply use a literal tuple as the key: