+ 1
How can i make the input accepts operations ?
ex : 3+5 == 5+3 ## If input is string the result will be wrong https://code.sololearn.com/cckNmfruQrHV/?ref=app
4 Answers
+ 2
Use eval();
print (eval("3+5"))
>>>8
print(eval("5+3"))
>>>8
print(eval("3+5") == eval("5+3"))
>>>True
+ 1
@blackcat1111
thank you
+ 1
@Weronika
it's already converted to float
0
>>> a = "34.7"
>>> float(a)
34.7