FAQ: Learn Python- Loops - For your hobbies

This community-built FAQ covers the “For your hobbies” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise For your hobbies:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

1 Like

A post was split to a new topic: Hobby choices

A post was split to a new topic: Not allowing me to give input on the second pass

2 posts were split to a new topic: Why Does the Exercise Ask for One Hobby and Print it Three Times?

Hi, can you explain why in the code the line is:
for num in range(3) - where does num come from? Why is it not for hobbies or for hobby in range(3)?
The num seems so random and out of nowhere!

Code 10.For Your Hobbies

because hobby or hobbies doesn’t accurately describe what the variable will hold. Giving logic variable makes code a lot more readable. Given range produces numbers/integers, num is a fair name.

In this particular instance we are using range as a counter, and have no real need of a variable. We can use a dummy placeholder with the same effect.

for _ in range(3):
2 Likes

I’m starting to get very frustrated. My code is exactly the same as the answer except for the string asking about your hobby. Surely CodeAcademy should count this as right since they do not tell you specifically what to put in the prompt?
Or is there something wrong with this I’m not seeing? I keep getting the error that the program took too long to terminate. Please help.

hobbies = []

# Add your code below!

for num in range(3):

  hobby = raw_input("What's your hobby?: ")

  hobbies.append(hobby)


print hobbies
1 Like

In the Python 2 track, raw_input() does not work. If you search the forums you will find this mentioned in numerous places, as well as how to work around it so you can see your code run.

1 Like