a question about zip...

Steve Holden steve at holdenweb.com
Thu Mar 9 02:43:02 EST 2006


KraftDiner wrote:
> I had a structure that looked like this
> ((0,1), (2, 3), (4, 5), (6,7)
> 
> I changed my code slightly and now I do this:
> odd = (1,3,5,7)
> even = (0,2,4,6)
> all = zip(even, odd)
> 
> however the zip produces:
> [(0, 1), (2, 3), (4, 5), (6, 7)]
> 
> Which is a list of tuples.. I wanted a tuple of tuples...
> 
So apply tuple() to the list!

all = tuple(zip(even, odd))

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd                 www.holdenweb.com
Love me, love my blog         holdenweb.blogspot.com




More information about the Python-list mailing list