This is my first post, so I apologize if I do anything incorrectly.
I am currently writing a simple program for a college class. The instructions for this specific part say:
The value of the entry MUST be “1”, or “2”, or “3”. There are different ways you can test for this.
You may create different validation techniques if you like as long as they work. If the entry is not valid, respond with an appropriate error message and re-prompt.
Now when I prompt the user to enter a selection (lets say they enter "1") it thinks it is an invalid input.
I personally think it should take the answer as an int
value but the instructions say it should not. Am I missing something small here?
I have tried editing the code with different '
and "
marks. I think I might be making a small syntax error but I can't put my finger on it.
cont= str("y")
cart = int(0)
item_total = int(0)
order_total= float(0)
cont=input("Would you like to place an order? ")
while(cont.lower() == "y"):
print("Order for John Doe")
print("1. Savannah")
print("2. Thin Mints")
print("3. Tagalongs")
item_n=input("Please choose a flavor ")
if(item_n != "1" or item_n != "2" or item_n != "3"):
print("Invalid entry, please try again")
else:
new_item=int(input("How many would you like (1-10)"))
I expect that if you enter a 1, 2, or 3 it will go into the else nest, but it does not. I can also post more of the professor's instructions if needed.