0
i dont understand why my code doesnt stop at 5
i = 0 while True: i = i +1 if i==2: print("continue") continue if i==5: break print(i)
5 Réponses
+ 2
i = 0
while True:
i = i +1
if i==2:
print("continue")
continue
if i==5: break
print(i)
+ 1
Because your block starting in line 7 is part of the block starting at line 4.
So if i==2, you don't get to the inner block, because there's the continue first, and if i!=2, you don't even enter this block to begin with.
Maybe you get the wanted result if you pull out the inner block one indentation level.
+ 1
The indentation is wrong. "if i==5:" is part of "if i==2:"
+ 1
Thank you so much