NOTE: Please read till the end, I don't want dictionaries.
For example, I have the global variable called var1
and I have the following:
i = 0
for i in range(0, 20):
var1 = i
i += 1
I want to create a new variable called var2
and store the value from the second iteration into that, instead of the initial var1
and so on for every iteration.
I also don't want to store it in some list var
and use var[i]
for every iteration.
I want the variable names to logically be named for every iteration.
Is there a direct solution or is there any way I can make a variable with the contents of a string?
The main intent of the question is to know if I can generate a new variable for every iteration with naming that has some logic behind it, instead of using lists.
Also, I do not want to define dictionaries as dictionaries have definite sizes and cannot flexibly expand themselves.