I wrote a function which looks up ages in a Dictionary and show the matching name:
dictionary = {'george' : 16, 'amber' : 19}
search_age = raw_input("Provide age")
for age in dictionary.values():
if age == search_age:
name = dictionary[age]
print name
I know how to compare and find the age but how do I show the name of the person. Also, I am getting a KeyError because of line 5. I know it's not correct but I can't figure out how to make it search backward.
How do I fix this problem?