I'm using a different similar longer code, but even while executing the following code I'm getting an error

Viewed 18
x=5

exec("a{}=x+5".format(1))

Output:

TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10972/452547662.py in <module>
      1 x=5
      2 
----> 3 exec("a{}=x+5".format(1))

TypeError: 'str' object is not callable
1 Answers

the following

x=5
exec("a{}=x+5".format(1))

works for me.

Is is wat you are trying to achieve ?

Related