Say I have a dictionary:
d = {
0: ('f', 'farm'),
1: ('m', 'mountain'),
2: ('h', 'house'),
3: ('t', 'forest'),
4: ('d', 'desert')
}
and the only information I'm given is the value h
. How can I retrieve 2
- the key that corresponds to h
- from the dictionary?
In other words, I don't have the whole tuple ('h', 'house')
to do a proper reverse lookup, I only have the h
. Is there an elegant way to do this?