d = {(1): 2, (3): 4, (5): 6, (7): 8, (9): 0}
last = len(d) - 1
for i, x in enumerate(d):
    if i == last:
        print(i, x, 'last')
else:
    print(i, x)
Identify which iteration you are on in a loop in python