Python配列遍歴

415 ワード

直接コード:
colours = ["red","green","blue"]

for colour in colours:
    print colour

# red
# green
# blue

第2の方法
colours = ["red","green","blue"]

for i in range(0, len(colours)):
    print i, colour[i]

# 0 red
# 1 green
# 2 blue