Re: comple list slices



Python lets you iterate through a list using an integer index, too,
although if you do so we will make fun of you. You can accomplish it
with a while loop, as in:

i = 0
while i < len(rows):
if rows[i] == "This code looks like BASIC without the WEND, doesn't
it?":
rowgroups.append("Pretty much.")
i += 1 # or i += rowspan, whatever.

Do not try to do this with a for loop. In Python, "for i in xrange(5)"
is more like a "foreach $i ( {0,1,2,3,4,5})" in Perl, so changing i in
the loop will not change the value of i on the next loop iteration.

.



Relevant Pages

  • Re: Looping using iterators with fractional values
    ... > question about constructing a loop that uses an iterator ... How does one do this in Python? ... Generally, you don't loop incrementing floating point values, as ... Or - and much safer when dealing with floating point numbers - iterate ...
    (comp.lang.python)
  • Re: iterating through files
    ... Sent from the Python - python-list mailing list archive at Nabble.com. ... Then use a loop to grab ... newFile = open ... Oops...I forgot to iterate the counter. ...
    (comp.lang.python)
  • Re: iterating through files
    ... Sent from the Python - python-list mailing list archive at Nabble.com. ... Then use a loop to grab ... newFile = open ... Oops...I forgot to iterate the counter. ...
    (comp.lang.python)
  • Re: iterating through files
    ... Sent from the Python - python-list mailing list archive at Nabble.com. ... Then use a loop to grab ... newFile = open ... Oops...I forgot to iterate the counter. ...
    (comp.lang.python)
  • Can you introduce some book about python?
    ... appending key-value pairs to a dict (Peter ... Is Python suitable for a huge, ... >> to the list on each loop... ...
    (comp.lang.python)