Reputation: 275
Have forgotten how to declare multiple conditions on a while loop
Its going to take one of the input and check the user has entered either of the 4 correct letters. Currently however, it always drops into the loop
temp = input()
while temp.lower() != ("a" or "b" or "c" or "d"):
print("Error, you must enter either A, B, C or D")
print(inventory())
print("What would you like to buy?")
temp = input()
Upvotes: 0
Views: 41
Reputation: 783
You might want to consider
while temp.lower() not in ('a','b','c','d'):
print("Error")
Don't know why one would do this but still here's an option:
import string
while temp.lower() not in string.ascii_lowercase[:4]:
print("Error")
Upvotes: 0
Reputation: 10890
Explicitely you would have to write
while (temp.lower() != "a") and (temp.lower() != "b")....... :
but you might want to try
while temp.lower()[0] not in 'abcd':
However, note the indexing I added here to the lowered input variable, as otherwise substrings of 'abcd'
of length > 1 would match, too.
Upvotes: 2