0

Can anyone explain why the following code is not working? i am trying to make a calculator

the following code keeps giving an error: print("Python Calculator") while True: num1 = int(input("please enter first number: ")) opera = input("please enter operation(+, -, *, /): ") num2 = int(input("please enter second number: ") if opera == "+" print("your total = " + str(num1 + num2)) print("-"*20) elif opera == "-" print("your total = " + str(num1 - num2)) print("-"*20) else print("syntax error")

10th Dec 2016, 1:19 PM
Dennis Wisse
Dennis Wisse - avatar
2 Antworten
+ 2
You forgot the colon : after the if,elif and else statements. if opera=='+': print (..
10th Dec 2016, 4:07 PM
lulugo
lulugo - avatar
0
yes but that gave an error as well, so when i did it without the colon it got an error at the print section
10th Dec 2016, 11:11 PM
Dennis Wisse
Dennis Wisse - avatar