I found a behaviour in Python which is slightly counter-intuitive (or rather not what I am used to!). So, I have some code as follows:
for c in range(10):
c += 1
print(c)
This prints
1
2
3
4
5
6
7
8
9
10
Even doing something like:
c = 0
for c in range(10):
...
Does not change the output? I guess the scoping rules are different than C++. My question is if someone needs to change the loop index within the function body, how could one do it?
cis set from therangeobject at the top of each loop. If you don't want that, use another kind of loop, like awhileloop, and increment the variable manually. It might make your code clearer anyway.