Simple errors


#1

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

and

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?


#2

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


#3

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: ")


#4

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