Iterating over indices in a list

Joakim Hove hove at ii.uib.no
Wed Feb 19 09:04:53 EST 2003


Hello all, 

I find my code quite often containing statements like this[*]:

  do index in (range(len(List))):
      if List[index]....


Somewhere I stumbled over a new, and more elegant (based on iterators
?) alternative to this ugly construction, but now I can not find
it. Any suggestions?


Regards - Joakim Hove

[*] I know I can do:

     do e in List:
         xxxx

    but that way I don't get access to the numerical indices, which I
    (sometimes) need for other purposes.


-- 
Joakim Hove  / hove at ii.uib.no  /  (55 5) 84076




More information about the Python-list mailing list