a question about zip...
Steven D'Aprano
steve at REMOVEMEcyber.com.au
Wed Mar 8 19:05:33 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...
Others have already told you how to do this. But I have
a question: why do you care that it is a tuple, not a
list? Is there something you need to do with it that
can be done with tuples but not lists?
In other words, while it isn't *wrong* to convert the
list to a tuple, perhaps it is *unnecessary*?
--
Steven.
More information about the Python-list
mailing list