「Python入門」for、enumerateでリストの要素を検索するサンプル

1.forループ
colours = [“yellow","red","green","blue"]
for colour in colours:
print colour

2.enumerate関数
colours = [“yellow","red","green","blue"]
for i, colour in enumerate(colours):
print i, colour

Python

Posted by arkgame