lundi 20 avril 2020

how to get two different random sample from one range in python

I am newer in python programming. And i want to get get two different random sample from one range in python.
I try something like this:

rd1 = random.sample(range(0, 10), 5) 
rd2 = random.sample(range(0, 10), 5)
print(rd1)
print(rd2)

>> red1 = [2, 4, 7, 6, 8]
>> red2 = [2, 4, 0, 7, 5]

But i want the red1 and red2 are no common elements like:

>> red1 = [1, 3, 9, 6, 8]
>> red2 = [2, 4, 0, 7, 5]

or

>> red1 = [0, 2, 9, 6, 1]
>> red2 = [3, 4, 8, 7, 5]

Somebody can help me and give me a solution ??
Thank you so much !




Aucun commentaire:

Enregistrer un commentaire