[英]How to convert 2D list python into one list with concate them
I have question here, and i have done to do what i can do, The problem is i have Multi List python 我在这里有疑问,我已经做了我能做的事情,问题是我有Multi List python
[[1,3,4,2],[2,2,3,1],[2,1,2,3]
i want make this list to become like this 我想让这个列表变得像这样
[[1,2,2],[3,2,1],[4,3,2],[2,1,3]]
Thanks in advance, 提前致谢,
its my code to try but separate into 2 list, i want make it into one like my question 我的代码尝试但分成2个列表,我想把它变成一个像我的问题
list1 = [1,4,2,5]
list2 = [2,1,5,3]
list3 = [list(a) for a in zip(list1, list2)]
list(map(list, zip(*list1)))
很简单。
@fianeka, Actually, it's even simpler than that :-) Of course if you a fine with list of tuples. @fianeka,实际上,它甚至更简单 :-)当然如果你对元组列表很好。
some_list = [[1,3,4,2],[2,2,3,1],[2,1,2,3]]
print(list(zip(*some_list)))
output: 输出:
[(1, 2, 2), (3, 2, 1), (4, 3, 2), (2, 1, 3)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.