I would like to do a calculation of a string that I get, for example:
var = '1+2'
I wanted to convert this string into an account, to return 3 for the variable var
and not '1 + 2', but this would not only be added, would have subtraction, multiplication and division, may still have a mixed operation, ex : var = '2*4+1'
and etc ... I think you already understand ...
The problem is that I get this account as string
I tried to use int(var)
, but not sure would have some function type calc(var)
?