Simple Errors (Am I doing it Right?)


#1


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

I typed in 'y' and 'n' and the code keeps going and going>

I not sure what is going to happen, am I doing it right?

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

while choice != 'y' or 'n' :  # Fill in the condition (before the colon)
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")


#2

In the above, the string, 'n' casts to True in a conditional expression, so this will always be True. False can never be an outcome of the whole expression.

choice != 'y' or choice != 'n'

Notice we have two distrinct expressions with two possible outcomes for each. That means False can be an outcome of the whole expression.


#3

I typed in the correct code and it still keeps going. How do I close the loop? Am I supposed to close the loop?


#4

Okay, now it comes down to logic. The or operator will find one case true when the other is false. Try using and. That way, when only one is false, the whole expression is false.


#5

I got now, thank you!:blush:


#6

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