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,526
  • 5
  • 37
  • 58
0
>>> exec("value = 10")
>>> print(value)
10
>>> exec("value = 11")
>>> print(value)
11
Marcel Preda
  • 898
  • 3
  • 14