[Tutor] Can anyone help me?
bgailer at alum.rpi.edu
Fri Oct 28 19:37:41 CEST 2005
At 08:03 AM 10/28/2005, Nathan Pinno wrote:
>I created it. Want to see the code?
>Here it is:
>numbers = 
Move this inside the loop following if q == 1 and get rid of the occurrence
of this statement following print numbers. Less code, easier to read, more
to the point.
> q = int(raw_input("Do you want a lottery number drawing? 1 for yes, 2
>for no "))
This could fail if user enters a string that does not represent an integer.
Either stick it in a try: block or leave the input character. I prefer the
latter as there is no advantage to treating it as a number.
> if q == 1:
> for i in range(6):
> draw = random.choice(range(1,50))
> print numbers
> numbers = 
> elif q == 2:
> print "Read the instructions please."
>For great sites go to: http://falcon3166.tripod.com
>MSN Messenger: falcon3166 at hotmail,com
>Yahoo! Messenger: spam_swatter31
>----- Original Message -----
>From: "Alan Gauld" <alan.gauld at freenet.co.uk>
>To: "Nathan Pinno" <falcon3166 at hotmail.com>; <Tutor at python.org>
>Sent: Friday, October 28, 2005 2:01 AM
>Subject: Re: [Tutor] Can anyone help me?
> > Nathan,
> > look at the functions in the random module.
> > randrange() would be one potential candidate.
> > Alan G
> > ----- Original Message -----
> > From: "Nathan Pinno" <falcon3166 at hotmail.com>
> > To: <Tutor at python.org>
> > Sent: Friday, October 28, 2005 3:07 AM
> > Subject: [Tutor] Can anyone help me?
> > Hey all,
> > I am trying to create a program that draws 6 numbers between 1 and 49 at
> > random for creating lottery tickets. I want to have a better chance when I
> > play. Can anyone help me code this or show me how to, please?
> > Thanks,
> > Nathan Pinno
> > For great sites go to: http://falcon3166.tripod.com
> > MSN Messenger: falcon3166 at hotmail,com
> > Yahoo! Messenger: spam_swatter31
> > ICQ: 199020705
> > AIM: f3mighty
>Tutor maillist - Tutor at python.org
More information about the Tutor