「Python入門」for inで配列の要素を取り出すサンプル
方法1 forループで配列の要素を取り出す
colors = [“red","green","blue"]
for color in colors:
print color
# red
# green
# blue
方法2 配列の長さを取得し、インデックスにより配列の要素を取り出す
colors = [“red","green","blue"]
for i in range(0, len(colors)):
print i, color[i]
# 0 red
# 1 green
# 2 blue