How does the range() differentiate the call being made in this case?
Example:
def ex():
list = [1,2,3,4]
for val in range(len(list)):
print(val)
break
for val in range(len(list)):
print(val)
break
Output -
0
0
In short, my question is why doesn't the output yield this way?
0
1
During the first call to the range() in the 'first for loop' , the call is 'range(len(list))', and in the first call to the range() in the 'second for loop', the call is 'range(len(list))' which the equivalent to the second call to the range() in the 'first for loop'. How does range() know if the call was from 'second for loop' and not 'first for loop'?