[Tutor] is it possible to traverse two lists simulatenously using python
Michiel Overtoom
motoom at xs4all.nl
Thu Apr 30 12:54:49 CEST 2009
Kent Johnson wrote:
> Use zip() or itertools.izip():
And when the sequences are of unequal length:
topgirls=["Ann","Mary","Casey","Zoe"]
richgirls=["Britt","Susan","Alice"]
print "\nUsing zip()"
for i,j in zip(topgirls,richgirls):
print i,j
print "\nUsing map()"
for i,j in map(None,topgirls,richgirls):
print i,j
--
"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Valloppillil
http://www.catb.org/~esr/halloween/halloween4.html
More information about the Tutor
mailing list