0
Help
for i in range(0,2): for i in range(0,4): print(i) Why do I get back 0 1 2 3 0 1 2 3 from the code and not 0 1 2 0 1 2 3 ? Thanks
2 Answers
+ 2
I wouldn't recommend re-using the same variable "i" this way. This can only lead to bugs and unexpected behaviour.
In any case The inner loop prints "0 1 2 3" and it is executed twice because of the outer loop.
That is why you get this output
+ 1
The code runs through to the inner loop and finishes it.
Then it jumps back to the outer loop and starts the whole thing once more.