In the provided code when you try to use i
in a for loop with range, it always changes to the number provided by range in the function without bothering to look at the increment made to i
. so basically if you try list(range(0, 10))
this will give you [0, 2, 3, 4, 5, 6, 7, 8, 9]
. so for goes through that list one by one without thinking if any changes were made to i
or not.
which if seen
loop_1: i=0
loop_2: i=1
loop_3: i=2
loop_4: i=3 (here now you increment value by 1), i=4
loop_5: i=4 (but the for loop was going though the list from range function so the change didn't do anything)
loop_6: i=5 (and so on until 9)