-1

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)
st1890
  • 1
  • Does this answer your question? [Shuffling a list of objects](https://stackoverflow.com/questions/976882/shuffling-a-list-of-objects) – Georgy Jan 15 '20 at 13:44

1 Answers1

0

Try to see Fisher-Yates shuffle. It's used for list randomization with no repetitions.

I hope that helps.

Mohammed Deifallah
  • 1,290
  • 1
  • 10
  • 25