[Tutor] 6 random numbers

Robert Sjoblom robert.sjoblom at gmail.com
Mon Oct 17 13:35:57 CEST 2011

>     print random.randrange(1,42)
> If you want to collect the intermediate results, either store them in a
> list:
> results = []
> for i in range(6):
>     results.append(random.randrange(1,42))

Gmail has removed the "Reply All" function for some ABSOLUTELY
RIDICULOUS REASON, so I think people missed my reply on this.

randrange is a horrible way to generate lottery numbers because it
doesn't generate unique numbers, and as for lotteries I don't think
I've seen a single one where they put the balls back before selecting
a new. random.sample is better because it does (for this purpose, at
least) and it stores the result in a list automatically.

Let's hope this email goes to the right thread. :/

best regards,
Robert S.

More information about the Tutor mailing list