[Tutor] AAAACCCKKK LOOPS :(

Britt A. Green python@experimentzero.org
Sat, 10 Aug 2002 10:34:09 -0700


If I understand you right, you want the loop to run until it gets a one or a
two, correct? Try something like this:

import random
while 1:
    mynum = random.randrange(1,13)
    print mynum
    if mynum < 3:
        print "*Click*"
        break
    else:
        print "Your Attempt Failed"

Note: I'm not at a computer with Python installed so the above code may need
a bit of tweeking.

--
"My mom says I'm cool."
----- Original Message -----
From: "Arie van Willigen" <rellik19@yahoo.com>
To: <tutor@python.org>
Sent: Saturday, August 10, 2002 10:25 AM
Subject: [Tutor] AAAACCCKKK LOOPS :(


>
> Hi Im having difficulty figuring out how to create a certain loop i wanted
to know how whould I have a random number generator continue to spit
outnumbers until it gets a one or a two. This is my current code:
>
> import random
> mynum = random.randrange(1,13)
> print mynum
> if mynum < 3:
>     print "*Click*"
> else:
>     print "Your Attempt Failed"
>
> thank you
>
>
>
>
>
>
> Me Myself And I... Oh Yeah Arie Too...
>
>
> ---------------------------------
> Do You Yahoo!?
> HotJobs, a Yahoo! service - Search Thousands of New Jobs