开发者

Python Vertical Array Slicing

开发者 https://www.devze.com 2023-03-10 23:32 出处:网络
Can anyone开发者_JAVA百科 show me how to slice the structure below: [[1, A], [2, B], [3,C]] Into two separate lists:

Can anyone开发者_JAVA百科 show me how to slice the structure below:

[[1, A], [2, B], [3,C]]

Into two separate lists:

[1, 2, 3]
[A, B, C]

I can obviously do this using code, but wondered if Python was able to do it natively?


my_list = [[1, A], [2, B], [3, C]]
a, b = zip(*my_list)

Note that a and b will end up being tuples.

0

精彩评论

暂无评论...
验证码 换一张
取 消