I want to have a for loop or similar that can instantiate variables in the loop, and then be available afterward. I know we often print things in for loops, but I want to actually be able to create variable names that correspond the loop number the for loop is on, and save something to that variable.
For example, suppose I have the below for
loop:
value = 10
for i in range(5):
value = i + value
print(value)
for which I will get print output:
10
11
13
16
20
But what if I want to actually create a new variable with each loop, with some prefix of my choosing like var
, so the first variable could end up being called var_one
(which would be 10 here), the second var_two
, etc.?
I want to create:
var_one = "Something"
var_two = "Something"
etc... in a loop
Make sure to notice how the suffixes are real English words!