+ 1

Now, i'm edited ; whats wrong

# calculater while True: add = "+" sub = "-" mul = "*" div = "/" quite = "exit" s = (("enter your oper: ")or mul) if (s == "quite"): break elif (s == add): num1 = float(input( )) num2 = float(input( )) rest = str(num1 + num2) print("\nthe ans is " + rest) elif (s == sub): num1 = float(input( )) num2 = float(input( )) rest = str(num1 - num2) print("the ans is " + rest) elif (s == mul): num1 = float(input( )) num2 = float(input( )) rest = str(num1 * num2) print("the ans is " + rest) elif (s == div): num1 = float(input( )) num2 = float(input( )) rest = str(num1 / num2) print("the ans is " + rest) else: print("plzz enter a number")

27th May 2020, 7:58 PM
Bruklin
Bruklin - avatar
5 Respuestas
0
You compare (s == "add") instead of (s == add) etc. Also you should have a look at the indentation of the last elif and the Else.
27th May 2020, 8:13 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 1
add 4 5 quite Works fine Unless you copied it from somewhere🤔🤔 because there are indentation errors I assume you could have correct yourself , Check the last elif and else statements
27th May 2020, 8:14 PM
Abhay
Abhay - avatar
+ 1
Manu- thnx for correction .
27th May 2020, 8:18 PM
Bruklin
Bruklin - avatar
+ 1
Abhay- no bro i not copied it, i just only focusing on my code not indentation.
27th May 2020, 8:19 PM
Bruklin
Bruklin - avatar
0
Hello Bruklin, check your code note that you have ideation problems in each line. In python it is not recommended to use () in the conditions of the statements. Note a bug, that when you capitalize the operation would not work for you, so accommodate it with the lower() It worked, and I organized the code a bit. I hope you like it. https://code.sololearn.com/cDrNnw4vCzpX/?ref=app
27th May 2020, 8:33 PM
Josshual A. Toro M.
Josshual A. Toro M. - avatar