I’m writing a calculator as my first project and i want the code to print a message and stop sequence if one of these 4 functions isn’t given ( + – * /), however the program still asks you for 2 numbers before it stops.
This is what i have
if operator == "+" or operator == "-" or operator == "*" or operator == "/":
num_1 = float(input("Chose number 1"))
num_2 = float(input("Chose number 2"))
else:
print(f"{operator} ain't right")
i have tried,
if operator == "+" or "-" or..
but it stills asks you for the numbers,
this does not happen when only one is in the if statement
New contributor
corporate greed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1