[Tutor] FW: 6 random numbers(again)

ADRIAN KELLY kellyadrian at hotmail.com
Mon Oct 17 20:24:18 CEST 2011




 
  
 

> Subject: Re: [Tutor] 6 random numbers
> From: shantanoo at gmail.com
> Date: Mon, 17 Oct 2011 01:53:18 +0530
> CC: tutor at python.org
> To: kellyadrian at hotmail.com
> 
> 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: 
> http://docs.python.org/tutorial/datastructures.html
> 
> -- 
> shantanoo
> http://xkcd.com/221/
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111017/4b35bf35/attachment.html>


More information about the Tutor mailing list