Why do my for loops have problems when using raw_input?


Hi all! Recently I’ve been doing the loops course in Learn Python, and I ran into a problem:

The code is supposed to “prompt the user three times for a hobby”, and it does, but very awkwardly. The first time it prompts the user it seems okay, but after you input the first hobby, the console immediately prompts you twice about your hobbies again, where it should only ask one at a time. Also, it should wait until after all three questions are asked (after the ‘for loop’) to print the list ‘hobbies,’ but it does so during this phase as if ‘coding’ is being appended to ‘hobbies’ thrice. Afterward, I can add two more inputs.

The code seems fine, but when the program runs it goes whack. However, I am still allowed to continue:

Does anyone know what is going on? :grimacing:


Before we try to troubleshoot, give the page a refresh and Run again. For the sake of simplicity, just use a short prompt.

 raw_input("Enter hobby: ")

Minimal verbosity is much simpler to debug. When everything is working then we can spruce up the output.


Oh thank you! It works fine now.


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