0
var_1 = "num_1"

how can I convert the string num_1 into a variable name?

For example, when num_1 is converted into a variable name it must be like num_1 = "Some other data"

sashkello
  • 17,306
  • 24
  • 81
  • 109

1 Answers1

0

The other duplicate questions and answers have long discussions of why this is generally a bad idea.

Are you sure you can't just use a dictionary to store your values?

var_1 = "num_1"
myvars = {}  # create an empty dictionary
myvars[var_1] = 99
print(myvars["num_1"])
Community
  • 1
  • 1
beroe
  • 11,784
  • 5
  • 34
  • 79