Simple Errors Question


#1

https://www.codecademy.com/courses/learn-python/lessons/loops/exercises/simple-errors

It keeps on repeating the the question with this code, and I know I’m supposed to use and. My only question is, why can I use and but not or?

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

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

#2

When we use and both operands have to yield True. When we use or only one has to be True.

Explanation

If you enter y the !='n' operand is true, and if you enter n the !='y' operand is true.

or is not the logic to use in the above expression.


#3

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