+ 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")
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.
+ 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
+ 1
Manu- thnx for correction .
+ 1
Abhay- no bro i not copied it, i just only focusing on my code not indentation.
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