Sunday, 15 May 2011

python - Appending raw input to a list -



python - Appending raw input to a list -

this simplest of exercises. don't understand why wont work.

here's code:

hobbies = [] in range(3): hobby = raw_input("name hobby") hobbies = hobbies.append(hobby)

basically want inquire user 3 times name 1 of hobbies, , store them in list. reason i'm getting error,

traceback (most recent phone call last): file "c:/python27/hobbies.py", line 4, in <module> hobbies = hobbies.append(hobby) attributeerror: 'nonetype' object has no attribute 'append'

which don't understand.

you should not utilize hobbies = hobbies.append(). instead utilize hobbies.append() only.

python list

No comments:

Post a Comment