samedi 2 avril 2022

How to use random.sample() within a for-loop to generate multiple, *non-identical* sample lists?

I would like to know how to use the python random.sample() function within a for-loop to generate multiple sample lists that are not identical.

For example, right now I have:

for i in range(3):
    sample = random.sample(range(10), k=2)

This will generate 3 sample lists containing two numbers each, but I would like to make sure none of those sample lists are identical. (It is okay if there are repeating values, i.e., (2,1), (3,2), (3,7) would be okay, but (2,1), (1,2), (5,4) would not.)




Aucun commentaire:

Enregistrer un commentaire