Counting iterations

Steven Bethard steven.bethard at gmail.com
Fri Apr 8 17:15:47 EDT 2005


Derek Basch wrote:
> Is there a better way to count iterations that this?:
> 
> pets = 0
> for i in pets:
>     pets += 1
>     print "pet" + "#" + pets

for i, pet in enumerate(pets):
     print 'pet#%i' % (i + 1)

STeVe



More information about the Python-list mailing list