+ 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":
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.
+ 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?
+ 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.
+ 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...