Get number of iteration

Paul Rubin http
Mon Feb 2 11:13:23 CET 2004


Jørgen Cederberg <jorgencederberg at hotmail.com> writes:
> Just nitpicking... :), but I guess you ment:
> 
> def enumerate(seq):
>      return zip(range(len(seq)), seq)

I think you want:

def enumerate(seq):
  for i in xrange(len(seq)):
     yield (i, seq[i])



More information about the Python-list mailing list