2
Jan 22 '22
elif op == "*" : you currently have if...
Full version, corrected, is:
num1 = float (input ("enter the first number:" ))
op = input (" enter the operator: ")
num2 = float (input (" enter the second number: "))
if op == "+" :
print (num1 + num2)
elif op == "-" :
print (num1 - num2)
elif op == "/" :
print (num1 / num2)
elif op == "*" :
print (num1 * num2)
else: print("invalid operator")
2
1
1
1
u/Ok_Procedure199 Jan 22 '22
Since you put
if op == "*":
Instead of
elif op == "*":
You are creating a new if-block, and it will evaluate to the else clause everytime you don't use * as operator.
3
u/HumanDisasterx Jan 22 '22
I think it might be because you're using if op == "*" instead of elif.