On Sunday, December 8, 2013 6:32:31 PM UTC, rafae...@gmail.com wrote: > On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: > > > On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: > > > > > > > i have a dictionary with names and ages for each name. I want to write a > > > function that takes in an age and returns the names of all the people who > > > are that age. > > > > > > > please help > > > > > > Welcome to the python list. Thanks for posting a question. > > > > > > > > > > > > If you were hoping for one of us to write the program for you ... well > > > > > > that's not what we do on this list. > > > > > > > > > > > > Please post the code you have so far and tell us exactly where you need > > > > > > help. > > > > > > > > > > > > Also tell us what version of Python, what OS, and what you use to write > > > > > > and run Python programs. > > > > name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', > 'Irene', 'Jack', 'Kelly', 'Larry'] > > age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] > > dic={} > > def combine_lists(name,age): > > for i in range(len(name)): > > dic[name[i]]= age[i] > > combine_lists(name,age) > > print dic > > > > def people(age): > > people=lambda age: [name for name in dic if dic[name]==age] > > > > people(20) > > > > > > > > > > this is the code i have so far(with the help of the first post ;p). i > understand how a function and a dictionary works and what I'm asked to find. > but i don't get the lambda age part. and this code doesn't give me any result
and I'm sorry but this is the first time i ask for help in a forum and i just didn't know how it works. I'm not looking for someone to do my homework i just need someone to help me with my code :) -- https://mail.python.org/mailman/listinfo/python-list