mardi 2 février 2021

I need to create a bunch of new lists and assign each list a set of randomly generated numbers

I'm trying to make a genetic algorithm and as an early step I need to generate a bunch of new variables/lists, each with a string of varying random numbers (genotypes) assigned to them at their creation.

I can create the values but I'm having trouble figuring out how to assign those values to new variables/lists that I can then reference later.

I tried this:

pool = ['I1', 'I2', 'I3', 'I4', 'I5']

for individual in pool:
    genotype = [random.randint(1,11) for value in range (9)]
    print (f"{individual}'s genotype is {genotype}")

But that only generates a string of random integers one time for each pool item. And I can't figure out how to assign those values to a each variable for future use.

I need to be able to have I1 = one set of #'s and I2 = another and then be able to use that outside the loop.

I know this is probably an easy problem but I've looked all over (probably in the wrong places) and can't figure out how to solve it. Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire