I would like to use a string to create a variable name.
For example, let’s say I have a list of strings:
caseName = ["A", "B", "C"]
I want to create different variables whose name would be "timeA"
, "positionxA"
, "timeB"
, "positionxB"
and "timeC"
, "positionxC"
.
How would I create those variables using caseName
list instead of manually creating them ?
I want to precise that I don’t want the name of the variable to be exactly the string: I saw a lot of post where they want this, which apparently was not a good idea (and recommendeded to create a dictionary instead).
jeirual is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.