Counting nested loop iterations

Jeffrey Schwab jeff at schwabcenter.com
Thu Mar 16 22:39:26 CET 2006


Derek Basch wrote:
>> Depending on the types of the containers in question, you could use:
>>
>> 	len(zoo) * len(animal)
> 
> I think this would give me the total iterations but I wouldn't be able
> to get a running count. Correct?

Correct.  If you need a running count, maintain a counter (or enumerate()).



More information about the Python-list mailing list