I have three lists, all containing several strings.
Main
Supplemental
Auxiliary
I'm trying to generate a new string from a combination of random elements of these. Main will have a defined indice, the other's indice can be fully random. The order that these come out should be random too.
This is what will get the job done
main = main[5]
supp = random.choice(supplemental)
aux = random.choice(auxiliary)
all = [main, supp, aux]
print(random.choice(all) + random.choice(all) + random.choice(all))
However, this isn't particularly elegant and poses a high chance of collision.
Is there a better way to think about this, and one that won't cause the same to list to be picked?
Aucun commentaire:
Enregistrer un commentaire