python programming help
ybmess at nooos.fr.invalid
Mon Dec 9 03:02:32 CET 2013
Le 08.12.2013 20:06, rafaellasav at gmail.com a écrit :
> i get it, thanks a lot i wrote a different one and it works
> def people(age):
> people=[name for name in dic if dic[name]==age]
No it doesn't. You are printing things not returning something.
and combine_list is the most stupidest function you could write
in Python, as it is built-in with the name 'zip'.
>>> 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 = dict(zip(name,age))
>>> def people(age):
... ''' How stupid it is to write three line for a one-line
... return [name for name in dic if dic[name]==age]
['Gary', 'Alice', 'Frank']
Sorry for having being rude, but :
1. you shouldn't post raw homework in any kind of public group
(aren't you supposed to learn something by yourself ?)
2. your teacher is a nut.
More information about the Python-list