Python の zip 関数を使ってみる
Python
Published: 2019-08-23

やったこと

Python の zip 関数を使ってみます。

確認環境

$ python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Sep 21 2017, 18:29:43)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

調査

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zip(x, y)
<zip object at 0x10ef954c8>
>>> for a, b in zip(x, y):
...   print(a, b)
...
1 4
2 5
3 6

参考