looping through two list simultenously

Björn Lindström bkhl at stp.lingfil.uu.se
Sun Oct 29 21:37:06 CET 2006


"CSUIDL PROGRAMMEr" <syedamjad_a at yahoo.com>:

> folks I have two lists
>
>  i am trying to loop thorough them simultenously.
>
> Is there any efficient doing this

Try the built-in function zip.

>>> zip(['a', 'b', 'c'], [1, 2, 3])
[('a', 1), ('b', 2), ('c', 3)]

-- 
Björn Lindström <bkhl at stp.lingfil.uu.se>
Student of computational linguistics, Uppsala University, Sweden



More information about the Python-list mailing list