I'm aiming to randomly take a sample of items from a list and then take a sample from that new list until only one item is left in the list.
Code:
from random import sample
exampleList = ["Gary","Kerry","Larry","Bob","Frank","Joshua"]
def reduce(List):
newList = sample(List, random.randint(1, len(List)))
return newList
reduce(reduce(reduce(reduce(exampleList)))) #<-- I want to avoid doing this#
Aucun commentaire:
Enregistrer un commentaire