I have a small script to get a random sample from a list, however I want to always get the same list whenever I run this script. How should I do this?
My code currently is as follows, however each time that I run the script, I get a different sample.
import random
def SampleWithoutRepetition(population, sampleSize):
random.seed(100)
result = random.sample(set(
map(lambda attribute: attribute, population)), sampleSize)
print(f"result: {result}")
population = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
SampleWithoutRepetition(population, 4)
Aucun commentaire:
Enregistrer un commentaire