LoginSignup
0
0

More than 3 years have passed since last update.

【python】enumerateの動作

Posted at

enumerateの動作が面白かったので記載する。

動作

enumerateは辞書をfor文に入れる時に非常に役に立つ。

d = {5:1, 6:2, 7:3}

上のような辞書をfor文に入れる。

for i, x in enumerate(d):
     print(i,x)
#0 5
1 6
2 7

上記からenumerateを実行すると
iには数列の番号が
xにはキーが
入る。

0
0
1

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
0
0