mercredi 15 janvier 2020

print random from list with no duplicate

I have 3 lists called animal, adjectives and group_members_b. The group_members_b list has 5 names and need to print them out to random selcetion from animal and adjectives list.

When i use the code below i get duplicates of the name. How would i get the 5 names printed so each name is used once?

for i in range (0,5):
        animal = random.choice(animal_types)
        adjectives = random.choice(adjectives_list)
        name = random.choice(group_members_b)

        print (name, "is a", adjectives, animal)



Aucun commentaire:

Enregistrer un commentaire