samedi 16 janvier 2021

Random genereator that removes items from a list after picking

I have a list with 48 items. I want to randomly pick out 3 of those items, then remove those three items from the list. After that, randomly pick 3 new items. I wish to loop this 16 times until all the items are removed.

I've tried a for loop. But I can't figure out how to remove those specific items that was randomly selected from the list. I'm pretty new at both Python and programming. Help would be much appreciated.

list = ['Pink', 'Red', 'Green', 'Darkgreen', 'Blue', 'Skyblue'] * 8

loop = np.arange(1,16)

for i in loop:
    print(random.sample(list, 3))



Aucun commentaire:

Enregistrer un commentaire