python conditional indexing for loop 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 iterate with index
for index, item in enumerate(iterable, start=1):
print index, item