Iterating by both element and index?...

Robert Kern robert.kern at gmail.com
Tue Sep 26 00:42:16 EDT 2006


kenneth.m.mcdonald at sbcglobal.net wrote:
> I'd like to iterate over a sequence by both element
> and index, something like
> 
> for (element, index) in somefun(sequence):
>     ...

for index, element in enumerate(sequence):
     ...

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list