python for index var code example
Example 1: python for loop index
presidents = ["Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson"]
for num, name in enumerate(presidents, start=1):
print("President {}: {}".format(num, name))
Example 2: python for loop with index
colors = ["red", "green", "blue", "purple"]
for i in range(len(colors)):
print(colors[i])