Zip list of tuples with flat list

前端 未结 1 1559
生来不讨喜
生来不讨喜 2021-01-19 01:43

I\'m wondering if there\'s an easy way to do the following in Python 3.x. Say I have two lists structured as follows:

list_a = [(1,2), (1,2), (1,2), ...]
lis         


        
相关标签:
1条回答
  • 2021-01-19 02:02

    You just need parentheses:

    list_a = [(1,2), (1,2), (1,2)]
    list_b = [3, 3, 3]
    for (a, b), c in zip(list_a, list_b):
        print(a, b, c)
    

    Result:

    1 2 3
    1 2 3
    1 2 3
    
    0 讨论(0)
提交回复
热议问题