I have been using Python random randint to generate five random number from certain range.
I need to run thousands of this random process.
However, I found that when the code run above thousands time, it begins to generate a lot of duplicated number.
here is my code:
list = random.sample(range(1, 4171), 5)
it supposes to generate five different number every time I run it, but when I run it like thousands of time, it begins to generate combination like:
[4171, 4171, 3624, 3843, 3921]
[4171, 4171, 3624, 3843, 3921]
[2024, 4171, 4171, 3596, 2960]
I don't understand why there are so many duplicated 4171 in the generated list?
Is there some kind of bug in it?
I just want the code to generate five different number in certain range.
Aucun commentaire:
Enregistrer un commentaire