Simple Errors- please help!


My Code

I get the initial "Are you enjoying the course" question, but when I answer, something weird happens. For example, I'll answer "f" to test the code, and the output will spit out "y" or "n" and I have to answer again. The code is not consistent and I'm very confused. I need to know what I'm doing wrong because this exercise is affecting my ability to do other exercises.

I expected that I only had to enter my answer once, unless it wasn't 'y' or 'n'.

Replace this line with your code. 
choice = raw_input('Enjoying the course? (y/n)')
choice == 'y' and 'n'
while choice != raw_input('y') and choice != raw_input('n'):
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")
if choice == 'y':
    print "Glad to hear!"
elif choice == 'n':
    print "Sorry to hear."


The above line is doing nothing so may be removed.

You already have a value in choice from the first line. The above line makes three separate calls to raw_input() meaning the user is asked for more inputs. Doesn't seem right, does it?

That whole loop can be removed. Just work with the if statement.


Thank you! My code worked properly. I didn't realize the raw_input would ask for more inputs. Thanks so much!


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