Issue
I have two list, and want to combine the two in one nested list, with comma separate them
list A
[[1,1],[1,2],[1,3]]
list B
[[2,1],[2,2],[2,3]]
Expected output is:
[
[[1,1],[2,1]],
[[1,2],[2,2]],
[[1,3],[2,3]]
[
Solution
Iterate two list by zip
a = [[1,1],[1,2],[1,3]]
b = [[2,1],[2,2],[2,3]]
c = [[i, j] for i, j in zip(a, b)]
print(c) # [[[1, 1], [2, 1]], [[1, 2], [2, 2]], [[1, 3], [2, 3]]]
Answered By - CN-LanBao
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.