interchanging rows and columns
Huaiyu Zhu
hzhu at users.sourceforge.net
Mon Oct 16 12:51:24 EDT 2000
On 14 Oct 2000 09:45:25 GMT, Johannes Zellner <johannes at zellner.org> wrote:
>how can I turn
> [[1, 2, 3], [4, 5, 6]]
>into
> [[1, 4], [2, 5], [3, 6]]
>
>?
>must be easy, but I couldn't manage it.
>I tried some (map|apply) variants of the tutorial. No luck.
>
Do you have Python 2.0?
>>> a = [[1, 2, 3], [4, 5, 6]]
>>> zip(*a)
[(1, 4), (2, 5), (3, 6)]
Huaiyu
More information about the Python-list
mailing list