I had no idea you could have an 'else' tied to a 'while' loop.
Interesting....
I looked this up in Python in a Nutshell. From p. 69:
The else Clause on Loop Statements
while and for statements may optionally have a trailing else clause. The statement or block under that else executes when the loop terminates naturally (at the end of the for iterator, or when the while loop condition becomes false), but not when the loop terminates prematurely (via break, return, or an exception). When a loop contains one or more break statements, you often need to check whether the loop terminates naturally of prematurely. You can use an else clause on the loop for this purpose:
for x in some_container:
if is_ok(x): break # item x is satisfactory, terminate loop
else:
print "Warning: no satisfactory item was found in container"
x = None
Dick Moores
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
