LoginSignup
1
1

More than 5 years have passed since last update.

Pythonで複数のリストをforで処理する

Posted at

メモ
以下のようにzipを使うと良いみたい

a = [1, 3, 5, 7]
b = [2, 4, 6]

for (a_num, b_num) in zip(a, b):
    print(a_num, b_num)

# 結果は以下の通り
# 1 2
# 3 4
# 5 6

lengthが短い方の処理が終わったら、そこで処理終了になるっぽい

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1