zip unzip?

Kevin Yuan farproc at gmail.com
Thu Dec 29 02:26:34 EST 2005


:)
He/She certainly knows. Just reminds us of zip! :);):)

2005/12/29, Fredrik Lundh <fredrik at pythonware.com>:
>
> KraftDiner wrote:
>
> > I have two lists...
> >
> > a=[1,2,3]
> > b=[4,5,6]
> >
> > n=0
> > for i in a:
> >    print i, b[n]
> >    n=n+1
> >
> > how can i have two iterators on my for loop?
> > rather than have to use the counter n?
> > like:
> > for i,j in a,b:
> >    print i, j
> >
> > Do you know what I mean?
>
> given your subject line, you seem to know what you mean.
>
>     for i,j in zip(a,b):
>         print i, j
>
> </F>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051229/a3201ef3/attachment.html>


More information about the Python-list mailing list