[Tutor] help

Michiel Overtoom motoom at xs4all.nl
Wed Jul 15 23:26:42 CEST 2009

jonathan wallis wrote:

> i cant figure out if there is a way to make so if one loop ends it says 
> something different than if the other loop ends.

Maybe you could use two separate tests and break out of the loop if x or 
y gets too low.
Because the tests are separated you could say something different for 
each case.
For example:

import random

while True:
     print "x is %d, y is %d" % (x,y)
     if x<=0:
         print "Loop stopped because X was too low"
     if y<=0:
         print "Loop stopped because Y was too low"
     # do something with x and y
     if random.random()>0.5:

"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Valloppillil

More information about the Tutor mailing list