How to zip two lists of lists in Python?

前端 未结 5 892
星月不相逢
星月不相逢 2020-12-09 09:19

I have two lists of lists that have equivalent numbers of items. The two lists look like this:

L1 = [[1, 2], [3, 4], [5, 6]]

L2 =[[a, b], [c, d], [e, f]]
         


        
5条回答
  •  一个人的身影
    2020-12-09 09:34

    You want to combine the sublists with the plus operator, and iterate over them in a list comprehension:

    Lmerge = [i1 + i2 for i1, i2 in zip(L1, L2)]
    

提交回复
热议问题