I need help with generating a list of specific random numbers using Python.
I know how to generate a list of random number like this
import random
number = random.sample(xrange(1,10), 3)
which will generate 3 random numbers between 1 to 10. (Example)
[7, 6, 1]
What I want to do achieve is generating a list of random numbers like this with duplicate value(Example)
[10000, 30000, 20000, 60000, 100, 3000, 3000, 100, ...]
But using above script like this
import random
number = random.sample(xrange(10000,100000), 4)
yields following result (Example)
[12489, 43177, 51867, 68831]
Is it possible to do what I want to achieve here? Thank your answer.
Aucun commentaire:
Enregistrer un commentaire