Re: python loops



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.

.



Relevant Pages

  • Re: python loops
    ... concise loops. ... In python, 'for' iterates over elements in a sequence. ...
    (comp.lang.python)
  • Re: python loops
    ... concise loops. ... In python, 'for' iterates over elements in a sequence. ...
    (comp.lang.python)
  • python loops
    ... concise loops. ... In python, 'for' iterates over elements in a sequence. ...
    (comp.lang.python)
  • Re: Scope rule pecularities
    ... > Python has immutable types at all, including in the commonly used builtins. ... > Immutability of strings, numbers and tuples has worked very well for Python ... > happens inside func. ... >> writing code that can work with any sequence becomes a possible ...
    (comp.lang.python)
  • lxml 1.0.2 and 1.1alpha released
    ... I'm happy to announce the release of lxml 1.0.2 and 1.1alpha. ... extends the ElementTree API significantly to offer support for XPath, RelaxNG, ... * Use Python unicode strings in API. ... Element.iterancestorsiterates over the ancestors of an element ...
    (comp.lang.python.announce)