
# Sometimes, you’ll want to iterate over a list and use both its elements and their
# indexes:

L = [4, 7, 1, 7]

# Not Pythonic:
for i in range(len(L)):
    x = L[i]
    print(i, L[i])
print()

# Another none-Pythnic way to keep track of the index is:

i = 0
for x in L:
    print(i, L[i])
    i += 1
print()

# The Pythonic solution is enumerate, which produces tuples (index, element):

for i, x in enumerate(L):
    print(i, L[i])
print()

# If we just want the indexes:

for i in range(len(L)): print(i) 	# not Pythonic

for i, _ in enumerate(L): print(i) 	# Pythonic

# We’ll use this a lot.
