+ 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

9th Jan 2020, 1:54 PM
Rashid Shakili
Rashid Shakili - avatar
1 Antwort
+ 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)
9th Jan 2020, 2:10 PM
HonFu
HonFu - avatar