Commit 83ca0a65 authored by Benjamin Peterson's avatar Benjamin Peterson

talk about how you can unzip with zip

parent cae5848f
......@@ -1387,6 +1387,18 @@ available. They are listed here in alphabetical order.
makes possible an idiom for clustering a data series into n-length groups
using ``zip(*[iter(s)]*n)``.
:func:`zip` in conjunction with the ``*`` operator can be used to unzip a
list::
>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> zipped
[(1, 4), (2, 5), (3, 6)]
>>> x2, y2 = zip(*zipped)
>>> x == x2, y == y2
True
.. versionadded:: 2.0
.. versionchanged:: 2.4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment