0

If I have a string like this "value = 10" how would I make it so the value is equal to 10

2 Answers2

0

You can use the built-in exec method:

exec("value = 10")
ApplePie
  • 8,814
  • 5
  • 39
  • 60
0
>>> exec("value = 10")
>>> print(value)
10
>>> exec("value = 11")
>>> print(value)
11
Marcel Preda
  • 1,045
  • 4
  • 18