[Python]enumerate()関数に引数を指定するサンプル

2021年7月27日

書式
enumerate(msgLst,開始値)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
msgLst = ['study', 'skill', 'in', 'arkgame', 'become', 'smart', 'Good']
print("enumerate関数の第2引数に開始値を指定")
for index,value in enumerate(msgLst,3):
print(index,value)
msgLst = ['study', 'skill', 'in', 'arkgame', 'become', 'smart', 'Good'] print("enumerate関数の第2引数に開始値を指定") for index,value in enumerate(msgLst,3): print(index,value)
msgLst = ['study', 'skill', 'in', 'arkgame', 'become', 'smart', 'Good']

print("enumerate関数の第2引数に開始値を指定")
for index,value in enumerate(msgLst,3):
    print(index,value)

結果
enumerate関数の第2引数に開始値を指定
3 study
4 skill
5 in
6 arkgame
7 become
8 smart
9 Good

Python

Posted by arkgame