simultaneous iteration of lists

Erik Max Francis max at alcyone.com
Wed Jul 17 02:27:50 EDT 2002


Dave Harrison wrote:

> Looking for advice on simultaneous iteration of two lists.
> 
> I have two lists of equal length (guaranteed) , and I want to iterated
> over both at the same time without having to write myself a little
> counter thingo cause it seems slightly unpythonic.

This is what zip is for:

	for i, j in zip(l, m):
	    ...

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ See the son in your bad day / Smell the flowers in the valley
\__/ Chante Moore
    Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
 A personal guide to Aliens vs. Predator 2.



More information about the Python-list mailing list