In the following code, I am trying to use the statement 'a = b - c' to edit the local variable a:
def fun1(a, b, c):
#a = b - c
print(locals())
exec('a = b - c', locals())
return a
print(fun1(1, 10, 20))
output:
{'c': 20, 'b': 10, 'a': 1}
1
I am unable to modify the local variable a: it should return -10.