[Tutor] 6 random numbers

शंतनू shantanoo at gmail.com
Sun Oct 16 22:23:18 CEST 2011

On 17-Oct-2011, at 1:13 AM, ADRIAN KELLY wrote:

> hello all,
> anyone know how i would go about printing 6 random numbers, i know i could copy and paste 6 times (which would work) but i was thinking about a while loop, ie. while lottery_numbers.count is <7. 
> Is it possible to code this? is it possible to count random variables? i am trying to keep the program as simple as possible, cheers
> any help would be welcome, 
> import random
> lottery_numbers=random.randrange(1,42)
> print lottery_numbers

Following example may be useful:
x = [random.randrange(1, 1+random.randrange(42) for _ in range(100)]

Useful read: 


More information about the Tutor mailing list