Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > zip unzip?

Reply
Thread Tools

zip unzip?

 
 
KraftDiner
Guest
Posts: n/a
 
      12-29-2005
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?

 
Reply With Quote
 
 
 
 
ZeD
Guest
Posts: n/a
 
      12-29-2005
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?

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      12-29-2005
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>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possibility to add a zip-file to a new zip-file with "add to zip" (right-click) ?? erikkie@casema.nl Computer Support 4 06-26-2006 12:18 AM
uploading and receiving zip file(java.util.zip) ? sunil_varma Java 1 02-06-2006 10:37 AM
java.util.zip.ZipException: error in opening zip file HARI OM Java 0 05-03-2005 05:02 PM
java.util.zip.ZipException: error in opening zip file hari_om@hotmail.com Java 0 05-03-2005 04:47 PM
java.util.zip - problem opening some legitimite me zip files Alex Hunsley Java 1 09-16-2004 02:06 PM



Advertisments