mardi 27 avril 2021

How to get the unselected population in python random module?

So, I know I can get a random list from a population using the random module,

l = [0, 1, 2, 3, 4, 8 ,9]

print(random.sample(l, 3))
# [1, 3, 2]

But, how do I get the list of the unselected ones? Do, I need to remove them manually from the list? Or, is there a method to get them too?

Edit: The list l from example doesn't contain the same items multiple times, but when it does I wouldn't want it removed more than it's selected as sample.




Aucun commentaire:

Enregistrer un commentaire