j = 2 print(f"j: {j}") l1 = [1,2,3] for j, data in enumerate(l1): # scope of j is in the for loop. scope should be as small as possible print(f"Sample {j+1}: {data}") print(f"j: {j}")