Peter Otten wrote:
Steven D'Aprano wrote:
# Get ten random samples, sampling with replacement.
samples = [random.choice(subset) for i in range(10)]
That may include subset items more than once.
Hence the "sampling with replacement" comment.
Use the aptly named
random.sample(subset, 10)
to avoid that.
Ah, I didn't know that one! Nice.
--
Steven
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor