do-while loop?

Charles Cazabon c_cazabon at hotmail.com
Fri Mar 24 04:12:59 CET 2000


Peter Bittner claimed in <38DAD9A8.CF0FC4AF at aston.ac.uk>:

>I'm missing a 'do-while' statement in Python.
>There's only 'for' and 'while' available, but how do I implement a loop
>that has to be executed at least once?
>Do I have to go the ungly way and state the same code before the loop?

No.  Try this:

while 1:
    	do stuff here
    	if (end condition):  break

Charles



More information about the Python-list mailing list