Similar questions have been asked to mine but not exactly the same. I'm creating a natural selection/evolution simulator, with X number of creatures. I want to dynamically create and name lists of statistics about that creature with a for loop. An example of what this could look like would be:
counter = 1
for i in range(x):
organism(counter) = []
organism(counter).append(whatever data I want to put in)
counter += 1
The desired output of this for loop if x = 3 would be 3 lists, titled: creature1, creature2, creature3, and containing whatever data I wanted to append in.
I know this exact thing can't be done, but is there another way to achieve the same functionality? I know about dictionaries, but you can't dynamically create variable NAMES (i.e. creature1, creature2, creature3) with those, and they aren't really the same.
Any help is greatly appreciated.
EDIT: The solution is to use a dictionary like this:
x=int(input("How many Creatures?"))
class Creature():
def stats(a,b,c,d):
statsls = [a,b,c,d]
return statsls
creatures = {i: Moosh.stats(i,i+1,i+2,i+3) for i in range(x)}
This will generate x number of lists with stats in them (the stats themselves aren't relevant.