Why reiterate "or choice" 4. Simple errors


#1

Hi I know I need to reiterate "or choice" part in my if statement but why ? This is what happens when I run it
"Enjoying the course? (y/n) d
Sorry, I didn't catch that. Enter again: d
None"
it doesn't go on. And doesn't stop when I answer 'y' or 'n' I'm not stuck but I don't understand.

choice = raw_input('Enjoying the course? (y/n)')
while choice != 'y' or 'n':
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")
    if choice == 'y' or 'n':
        break

this on the other hand works

choice = raw_input('Enjoying the course? (y/n)')
while choice != 'y' or 'n':
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")
    if choice == 'y' or choice == 'n':
        break

#2

I think it's this.

Python probably doesn't understand and would probably make it so you would have to type both y and n.

This however, makes it clear that the answer can be y or n.
Hope this helps.:grinning:


#3

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