zip unzip?

Discussion in 'Python' started by KraftDiner, Dec 29, 2005.

  1. KraftDiner

    KraftDiner Guest

    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?
     
    KraftDiner, Dec 29, 2005
    #1
    1. Advertising

  2. KraftDiner

    ZeD Guest

    Ciao, KraftDiner! Che stavi dicendo?

    > 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?


    for i,j in zip(a,b):
    print i,j

    --
    Quante sono le persone
    che sanno leggere il codice esadecimale,
    se ci sono de11e persone
    che sanno leggere il codice esadecimale?
     
    ZeD, Dec 29, 2005
    #2
    1. Advertising

  3. 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>
     
    Fredrik Lundh, Dec 29, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Green

    How do I unzip a zip file

    Green, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,310
    Steve C. Orr [MVP, MCSD]
    May 5, 2005
  2. bradley

    zip / unzip uploaded files seamlessly

    bradley, Jun 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    560
    AlexL [Xceed]
    Jun 10, 2005
  3. italo

    Zip and UnZIP ASP.NET

    italo, Oct 18, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    13,275
  4. C B
    Replies:
    4
    Views:
    4,662
    Chris Uppal
    Nov 10, 2004
  5. Rocky Zhou
    Replies:
    0
    Views:
    610
    Rocky Zhou
    Apr 2, 2007
Loading...

Share This Page