I wanted to create a list(length of list 100) of unique random number from say range 0 to 100, such that no number repeats twice.
I know I can do that it using random.sample()
block = random.sample(range(0,100),100)
But I wanted to use seed in this, so I wanted to use numpy random seed and generate 100 unique numbers from a given set.
CodePudding user response:
I'm not sure you need numpy for this. Python's random
library allows you to set the seed as well.
random.seed(5)
block = random.sample(range(0, 100), 100)
CodePudding user response:
You can use np.random.shuffle
:
np.random.seed(123456)
l = list(range(100))
np.random.shuffle(l)