0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ちょっとした Pythonでの知識 (enumerate 型)

Posted at

Python には enumerate というデータ型が備わってます。
いったい何に使うデータ型でしょうか?
簡単に説明するとリストの要素とインデックスをfor文で同時に取得します。
↓↓↓サンプルプルプログラムです↓↓↓

sample.py
risuto =[
 "poteto",
 "ninnzinn",
 "玉葱",
 "kome",
]
for indekkusu, youso in enumerate(risuto):
    print(youso, indekkusu)

出力

poteto 0
ninnzinn 1
玉葱 2
kome 3

私の中ではすごい役に立っています。
使えるときは使えるので、是非、活用してください。
最後まで見ていただきありがとうございました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?