var1 = float(input("Variable 1:"))
operator = input("Write your operator:")
if operator == "+" or "/" or "*" or "-" or "**":
var2 = float(input("Variable 2:"))
if operator == "+": # Addition
print(f"{var1} + {var2} = ")
print(var1+var2)
elif operator == "*": # Multiplication
print(f"{var1} * {var2} = ")
print(var1 * var2)
elif operator == "/": # Division
print(f"{var1} / {var2} = ")
print(var1/var2)
elif operator == "-": # Subtraction
print(f"{var1} - {var2} = ")
print(var1 - var2)
elif operator == "**": # Power
print(f"{var1} ** {var2} = ")
print(var1 ** var2)
else:
print("Invalid operation, enter a correct operator")
I have just started to programme in Python and I have decided to create a calculator that does basic mathematical operations. It is supossed to work correctly when I put the correct symbol into the "operator" variable, but when I put some random letter it does not run the command "else". Why does this happen?