Re: comple list slices
- From: johnzenger@xxxxxxxxx
- Date: 28 Feb 2006 08:13:20 -0800
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.
.
- Follow-Ups:
- Re: comple list slices
- From: William Meyer
- Re: comple list slices
- References:
- comple list slices
- From: William Meyer
- comple list slices
- Prev by Date: Re: PEP 354: Enumerations in Python
- Next by Date: Re: Vectorization and Numeric (Newbie)
- Previous by thread: Re: comple list slices
- Next by thread: Re: comple list slices
- Index(es):
Relevant Pages
|