Python
Python3

forループ内でリストの添字と値を同時に取得できるenumerate

foods = ["apple", "banana", "candy", "donuts"]

# こういうことをしたい
for i in range(len(foods)):
    print("foods[{}] = {}".format(i, foods[i]))
#foods[0] = apple
#foods[1] = banana
#foods[2] = candy
#foods[3] = donuts

# enumerateを使えばシンプル
for i, food in enumerate(foods):
    print("foods[{}] = {}".format(i, food))
#foods[0] = apple
#foods[1] = banana
#foods[2] = candy
#foods[3] = donuts

# 第二引数を与えるとiはその値から始まる
for i, food in enumerate(foods, 100):
    print("foods[{}] = {}".format(i, food))
#foods[100] = apple
#foods[101] = banana
#foods[102] = candy
#foods[103] = donuts