python: combine 2 ordered lists into list of tuples

前端 未结 5 754
轮回少年
轮回少年 2021-01-17 05:04

I have 2 lists that I want to combine into a single list of tuples, so that order is maintained and the result[i] is (first[i], second[i]). Assume

5条回答
  •  孤城傲影
    2021-01-17 05:37

    Python has a function for that:

    >>> zip(first, second)
    [(1, 4), (2, 5), (3, 6)]
    

    zippedy-doo-dah

提交回复
热议问题