For your hobbies


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

print hobbies

Code returns:

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

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


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.


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!


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