Https://www.codecademy.com/courses/learn-python/lessons/python-2-loops/exercises/for-your-hobbies

The interpreter is claiming that I haven’t included “raw_input()” in my code, but I clearly have. What am I doing wrong? the code clearly works.

hobbies = []

# Add your code below!
for index in range(3):
  prompt = raw_input ("Input:")
  hobbies.append(prompt)
print "Your hobbies are:"
for passtime in hobbies:
  print passtime

Hey @ssorbom!

It may be the space between the parentheses and the raw_input function:

for index in range(3):
  prompt = raw_input ("Input:")
                    ^

Hope this helps!
Steven

2 Likes

Will try soon, thanks.

1 Like

If the exercise asks for at least three hobbies, that does not restrict us to three, just no less than three. Therefore a literal limit on inputs is not expected.

In cases like this where there is user input within a loop, we need to give the user a means of exiting the session.

Consider,

hobbies = []
abort = 'xX'
while True:
    u = raw_input("(X=Exit) Hobby: ")
    if u in abort:
        if len(hobbies) > 2: break
        print "Need more hobbies..."
    else:
        hobbies.append(u)

print "Your hobbies are:"
for hobby in hobbies:
    print hobby
3 Likes

That worked! I appreciate your help. Thank you!

1 Like