badoobadee
badoobadee

Reputation: 1

how can I matching sublists

I have data look like this

a = [[a,b,c],[d,e,f]]
b = [[1,2,3],[4,5,6]]
c = [[1,1,1],[2,2,2]]

How can I have result like

[[[a,b,c],[1,2,3],[1,1,1]],
[[d,e,f],[4,5,6],[2,2,2]]]

Thank you for any help

Upvotes: 0

Views: 23

Answers (1)

j1-lee
j1-lee

Reputation: 13939

You can use zip:

a = [['a','b','c'],['d','e','f']]
b = [[1,2,3],[4,5,6]]
c = [[1,1,1],[2,2,2]]

output = list(zip(a, b, c))
print(output) # [(['a', 'b', 'c'], [1, 2, 3], [1, 1, 1]), (['d', 'e', 'f'], [4, 5, 6], [2, 2, 2])]

Upvotes: 1

Related Questions