Simple Errors Loops


#1

What is wrong with my code?

choice = raw_input('Enjoying the course? (y/n)')

while choice != 'y' and choice != 'n':
choice = raw_input("Sorry, I didn't catch that. Enter again: ")


#2

Please provide a link to the exact exercise so we can check it. Thanks.


#3

https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/4?curriculum_id=4f89dab3d788890003000096


#4

What error message are you getting?


#5

Traceback (most recent call last):
File "python", line 4, in
File "", line 1, in
NameError: name 'y' is not defined


#6

When you input y in the prompt.


#7

Let us have another look at your current code...


#8

choice = raw_input('Enjoying the course? (y/n)')

while choice != 'y' and choice != 'n':
choice = raw_input("Sorry, I didn't catch that. Enter again: ")


#9

Could it be an indentation error?


#10

it was a indentation error i checked it and it worked


#11

2 posts were split to a new topic: Why I can't use "OR" instead of "AND"


#13