For your hobbies, running but not finishing


#1

https://www.codecademy.com/courses/learn-python/lessons/loops/exercises/for-your-hobbies?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
No error messages are appearing. Instead, the code does not finish once it runs, and does not allow me to finish it.

<What do you expect to happen instead?>
Every time I try to run this code, it runs infinitely, but I cannot enter anything.

hobbies = []

for i in range(3):
  hobby = int(raw_input("Name a hobby: "))
  hobbies.append(hobby)

print hobbies

#2

Remove the int() wrapper


#3

That has done little, the code continues to loop

hobbies = []

for i in range(3):
hobby = raw_input("Name a hobby: ")
hobbies.append(hobby)

print hobbies


#4

Does anyone have the answer to this? Nothing I’ve tried works.


#5

Is your code indented like this,


hobbies = []

for i in range(3):
    hobby = raw_input("Name a hobby: ")
    hobbies.append(hobby)

print hobbies

#6

Yes it is, I don’t know how that would change a loop anyway. I’ve looked at old posts, and it seems this is an issue that has never been resolved.


#7

Your code is absolutely fine, try resetting the workspace and writing the code again. :slightly_smiling_face:


#8

Figured out what the problem was, apparently when the code first appears it does not have a “hobbies” list created, and it appears the exercise can’t accept two instances of the same list. When I reset the workspace, it appeared just fine. Kind of bizarre.


#9

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