+ 1

Why i can't run it in playground.

while True: print("add for addition") print("sub for substraction") print("mul for multiplication") print("div for division") userin = input(": ") x = float(input("a:")) y = float(input("b:")) resultadd = str(x + y) resultsub = str(x - y) resultmul = str(x * y) resultdiv = str(x / y) if userin == "add": print("result is " + resultadd) elif userin == "sub": print("result is " + resultsub) elif userin == "mul": print("result is " + resultmul) elif userin == "div":

8th Apr 2018, 1:22 AM
ALBERT SAURAV
ALBERT SAURAV - avatar
5 Answers
+ 6
You could also have: 1. invisible control characters from copy+pasting and 2. you may need to separate your inputs with enter in the input dialog.
8th Apr 2018, 2:07 AM
Kirk Schafer
Kirk Schafer - avatar
+ 4
It depends on what's happening ... I can think of 3 things to check and want to narrow the field. What do you see? Can you post a code link so we can look?
8th Apr 2018, 1:44 AM
Kirk Schafer
Kirk Schafer - avatar
+ 4
As posted, your missing the statement required by the "div" elif. You should have a userin value to exit the infinite loop. The fact that you perform all operations prevents my adding 5 & 0 as a divide by zero will occur.
8th Apr 2018, 2:02 AM
John Wells
John Wells - avatar
29th Apr 2018, 3:20 PM
Programmer Gaurav
Programmer Gaurav - avatar
+ 1
yes wells sir..... it was a mistake....(during copy paste) actually I wrote my code in a app named pyroid ....there I can it run but I am unable to do it here in play ground.... hence I can't post it here...
8th Apr 2018, 10:41 AM
ALBERT SAURAV
ALBERT SAURAV - avatar