do-while loop?

Charles Cazabon c_cazabon at hotmail.com
Thu Mar 23 22:12:59 EST 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