ewok - 3 months ago 13x

Python Question

I have 2 lists that I want to combine into a single list of tuples, so that order is maintained and the

`result[i]`

`(first[i], second[i])`

`>>> first = [1,2,3]`

>>> second = [4,5,6]

>>> combine(first, second)

[(1,4), (2,5), (3,6)]

I've tried a few things

`[(i,j) for i in first, j in second]`

[(i for i in first, j for j in second)]

[(i,j) for i,j in first, second]

None of these work. I'm just wondering if this is possible or if I have to do it using a loop.

Source (Stackoverflow)

Comments