I'm doing some coding where it would be useful to reference variables named partially after another variable.
Something like this, but i in the variable name "variablei" changes to the value of i (variable0, variable1, etc.).
for i in range(0,10):
print(variablei)
I tried thinking of ways this could be done in Python but variable[i] refers to the ith variable in, for example, the list called variable.
I know that this could be fixed using lists where instead of naming things like "variable1", "variable2" etc. you could just append a list called variable. But, I'm trying to reference many objects that have already been created by others.
Perhaps there's a way to list the variable names in the environment, search for a variable with a number concatenated on it, and then get the value of that variable? I'm sure there is, but perhaps there's an easier way?