python programming help
breamoreboy at yahoo.co.uk
Sun Dec 8 20:21:22 CET 2013
On 08/12/2013 19:06, rafaellasav at gmail.com wrote:
> 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]
> i have one last question
> it asks me to test my program function by running these lines:
> print ’Dan’ in people(18) and ’Cathy’ in people(18)
> print ’Ed’ in people(19) and ’Helen’ in people(19) and\
> ’Irene’ in people(19) and ’Jack’ in people(19) and ’Larry’in
> print ’Alice’ in people(20) and ’Frank’ in people(20) and ’Gary’ in
> print people(21) == [’Bob’]
> print people(22) == [’Kelly’]
> print people(23) == 
> but when i wrote these lines it returns me an error
> Traceback (most recent call last):
> File "/Users/rafaellasavva/Desktop/people.py", line 19, in <module>
> print 'Dan' in people(18) and 'Cathy' in people(18)
> TypeError: argument of type 'NoneType' is not utterable
> do you know what it might be wrong?
You've typed up the error message instead of using cut and paste, which
is why it says "utterable" instead of "iterable"? :) Seriously, it's
already been pointed out that your people function needs a return
statement. Without it, the default returned is always None.
Would you also please read and action this
https://wiki.python.org/moin/GoogleGroupsPython as it prevents us seeing
huge numbers of unwanted newlines which some find extremely irritating.
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
More information about the Python-list