Newbie

For a long time, I’ve been using this Python idiom when I needed both the list indices and the list elements:

for index in range(len(L)):
    print index, L[index]

Only today, I realized there’s a much more elegant way to do the same:

for index, element in enumerate(L):
    print index, element

Gosh, I feel like such a newbie even after more than two years of using Python now!