NAMES = ['Alice', 'Bob','Cathy','Dan','Ed','Frank',
'Gary','Helen','Irene','Jack', 'Kelly','Larry']
AGES = [20,21,18,18,19,20,20,19,19,19,22,19]
def nameage(a,b):
nameagelist = [x for x in zip(a,b)]
nameagedict = dict(nameagelist)
return nameagedict
def name(a):
for x in nameage(NAMES,AGES):
if a in nameage(NAMES,AGES).values():
print nameage(NAMES,AGES).keys()
print name(19)
I am trying to return the names of the people aged 19. How do I search the dictionary by value and return the key?