Le 08.12.2013 20:06, rafaella...@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]
     print(people)

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
             function'''
 ...     return [name for name in dic if dic[name]==age]
 ...
 >>> people(20)
 ['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.




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to