So this is more of a general question (as opposed to one looking for a specific line of code). Let's say you have a repeated process that generates an output. What is usually the best practice for storing the output so that it is easily accessible and ideally stored by name, where name is a variable as well? For example, I may have something like:
for i in range(5):
output = i * 5
- Is there a way to assign the output of each iteration of your loop to a variable? So that the variable name itself is produced by the loop. For example "trial0" is equal to 0, "trial1" is equal to 5, "trial2" is equal to 10, etc... And thus after doing the loop, I have constructed 5 new variables that I can use later on.
- Would you be able to do something similar with dictionaries so that the key of the dictionary is produced by the loop and the items within that key are the output values?
In other words, what's the best way/best practice for storing the output of a repeated task and so that it is easily accessible and identifiable by something other than index value. I would like to easily refer to the output each time as opposed to referring it like list[1] or something.