+ 1
Why this continue statement don't work as intended
Hi, guys I was learning Continue statement in Python, and tried to change the code a little bit, but now continue doesn't skip 5 and continue with the next iteration. Instead it includes 5. Someone help please. Here is the code https://code.sololearn.com/c1k1GqKwW05Y/?ref=app
1 Respuesta
+ 4
You print i before the if condition, so it is printed, and then you go on with the next round.
With a different order, it works:
while 1 == 1:
i = i + 1
if i == 5:
print ("skipping 5")
continue
print (i)