Automatic increment
Neil Cerutti
horpner at yahoo.com
Thu Nov 30 13:33:05 EST 2006
On 2006-11-30, Thomas Ploch <Thomas.Ploch at gmx.net> wrote:
> Gheorghe Postelnicu schrieb:
>> Hi,
>>
>> I have a situation of the following type:
>>
>> for line in lineList:
>> for item in line.split()
>> myArray[counter, itemCounter]
>> itemCounter = itemCounter + 1
>> counter = counter +1
>>
>> Is there a way to get rid of the manual incrementation of the 2 counters?
>>
>> Thanks,
>
> for counter in xrange(len(lineList)):
> for itemCounter in xrange(len(lineList[counter].split()))
> myArray[counter, itemCounter]
I was going to suggest replacing the whole loop with nothing as
the best way of removing the manual counters.
--
Neil Cerutti
More information about the Python-list
mailing list