Is it safe to read loop variable after loop (using Python 2)? My purpose is to check how many iterations in the loop are done.
Here is code to show the idea:
a=[1,2,3,4,5]
for i in range(len(a)):
if a[i] == 2:
break
print i # output is 1, is it safe to read i here?