For your hobbies


#1



10. For your hobbies


Code passes but does not print hobbies. Prints indexes?


hobbies = []

for i in range(3):
    str(raw_input("Tell me your hobby: ")), i
    hobbies.append(i)

print hobbies

Code returns:

"
Tell me your hobby: Eat
Tell me your hobby: Sleep
Tell me your hobby: Code
[0, 1, 2]
None
"

I've seen other answers and I understand them. I just don't understand why my code returns this result. Help! Thank you!


#2

You are appending i to hobbies, but i is just a number in range(3), so 0, 1, 2. You need to append the input from the user.


#3

That makes sense. I don't know why I thought I remembered adding an argument to the raw_input command assigned the input to that variable. Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.