I can't figure out why this while loop is not working properly.
bday = input("Has your birthday already passed? (y|n) : ")
print(bday)
while True:
if (bday != 'y' or bday != 'Y' or bday != 'n' or bday != 'N'):
print("Invalid input, please enter Y or N.")
print(bday)
bday = input("Has your birthday already passed? (y|n) : ")
else:
break
According to my print statements, my values for "bday" are correctly seen as "y", "Y", "n", or "N". However, for some reason the condition acts as if it is the wrong value.
Originally coded as:
while (bday != 'y' or bday != 'Y' or bday != 'n' or bday != 'N'):
print("Invalid input, please enter Y or N.")
print(bday)
bday = input("Has your birthday already passed? (y|n) : ")
Thanks for any help.
ifstatement should beanded together. Currently, regardless of input, that condition will always be true.'y', 'Y', 'n', 'N'. It's impossible for a string to be equal to all of those.