Simple errors


So I got the excersice right afetr few tries. I was going about it the wrong way but I still dont know whats the difference between:

while choice != "y" and choice != "n": #do something


while choice != "y" or "n": #this format wont work but i still dont understand why. To me it seems it still follows all the rules in python. doesnt it?


you need to do comparison at both sides of the and or or operator, otherwise python will simply validate if 'n' is considered true

you need the and operator, this won't work with or operator


try this one! it looks more advance

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


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