python loops

AlbaClause you at cogeco.ca
Thu Aug 31 14:56:23 EDT 2006


Putty wrote:

> In C and C++ and Java, the 'for' statement is a shortcut to make very
> concise loops.  In python, 'for' iterates over elements in a sequence.
> Is there a way to do this in python that's more concise than 'while'?
> 
> C:
> for(i=0; i<length; i++)
> 
> 
> python:
> while i < length:
> i += 1

for i in range(length):
        print i


-- 
--
There are several things that I will never be:
  *  I will never be attracted to females.
  *  I will never enjoy the company of others.
Exactly how these realities bode for my enemy, is not of my concern.




More information about the Python-list mailing list