0

my code is something like this:

something = True

for i in range(5):
    if something: 
        for ii in range (2):
            print(i)
            i += 1
        something = False

    print(i) 

The output is:

0
1
2
1
2
3
4

But what I expect is 0 to 4 because the i is manipulated in the ii-loop. What's wrong in my code?

cactie
  • 111
  • 1
  • 7

0 Answers0