Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k points)

I have a list of tuples, where I want to unzip this list into two independent lists. I'm looking for some standardized operation in Python.

>>> l = [(1,2), (3,4), (8,9)] 

>>> f_xxx (l) 

[ [1, 3, 8], [2, 4, 9] ]

I'm looking for a succinct and pythonic way to achieve this.

Basically, I'm hunting for the inverse operation of zip() function.

1 Answer

0 votes
by (106k points)

You can use zip(*list):

>>> l = [(1,2), (3,4), (8,9)] 

>>> list(zip(*l)) 

[(1, 3, 8), (2, 4, 9)]

Related questions

+3 votes
2 answers
0 votes
1 answer
0 votes
2 answers
asked Jul 6, 2019 in Python by Sammy (47.6k points)

Browse Categories

...