0
Calculator in 4 lines of code. Can I make it work?
I thought of result in this way so I don't need to use "if" but it's 1st thing I wrote in life with less than basic python knowledge. If "x + y" work why can't I make operator as a variable and do math automatically like that "x y z" without writing 10 elifs. https://code.sololearn.com/c41Ox2ZOnOrA/?ref=app
3 Respuestas
+ 6
Hum. Like you kind of can but you still need to compare somehow before transforming.
Here try the best answer of below post:
https://stackoverflow.com/questions/2983139/assign-operator-to-variable-in-JUMP_LINK__&&__python__&&__JUMP_LINK
+ 1
Thanks Anya I will try to make it with this help. Becouse to me in this case it still looks better than whole if statment
0
It won’t work because it will consider the inputed operator as a string and not a command