do...while loops

Jay O'Connor joconnor at cybermesa.com
Tue Feb 6 14:43:29 EST 2001


On Tue, 6 Feb 2001 14:15:16 -0500, D-Man <dsh8290 at rit.edu> wrote:

>On Tue, Feb 06, 2001 at 04:15:21PM +0000, Jay O'Connor wrote:

>| Umm..then how about a counter?  Would this work?
>| 
>| x = 100
>| while x:
>| 	print x
>| 	x -= 1
>| 
>| Yeah, just tried it...it works.
>| 
>| Umm...anyone really like it? :)
>
>for x in range( 100 , 0 , -1 ) :
>	print x
>
>
>With for you only have 1 one line that describes the entire loop,
>instead of 3 lines that are spread about.  You also have no chance of
>forgetting to (de/in)crement the counter when you get to the end of
>the loop body.

Oh, I agree totally, for the reasons you mention.  I thought it was
goofy which is why I put the smiley 

I was just trying to think of a practical (?) use for doing a "while"
loop with a number other than 1

Take care,
Jay O'Connor
joconnor at cybermesa.com
http://www.cybermesa.com/~joconnor

Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython

"God himself plays on the bass strings first, when he tunes the soul"



More information about the Python-list mailing list