I am trying to execute exec('global expression_result; expression_result = %s' % "a += 2")
in python.
It is giving me SyntaxError
. I have already declared the variables a and expression_result
.
In ipython, I have also tried i = (a += 2)
this is also giving the SyntaxError
How to evaluate these kinds of expressions and get the result?