Blog Rizauddin
And He found you lost and guided [you]. [93:7]
Pages
Home
Python
LaTeX
Linux
Windows
Travelog
About
Showing posts with label
unzip
.
Show all posts
Showing posts with label
unzip
.
Show all posts
Tuesday, February 24, 2009
Unzip a Python list
Suppose that you have a list with tuples as the member.
>>> test = [('x',1), ('y',2), ('z',3)]
We can unzip the list by using zip() in conjunction with the * operator.
>>> a, b = zip(*test)
>>> a
('x', 'y', 'z')
>>> b
(1, 2, 3)
Older Posts
Home
Subscribe to:
Posts ( Atom )