python matrix transpose and zip

后端 未结 6 1122
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 11:32

How to get the transpose of this matrix..Any easier ,algorithmic way to do this...

1st question:

 Input  a=[[1,2,3],[4,5,6],[7,8,9]]
 Expected outpu         


        
6条回答
  •  攒了一身酷
    2020-11-30 11:47

    You can use list(zip(*a)).

    By using *a, your list of lists can have any number of entries.

提交回复
热议问题