+ 1
In the continue Loop - i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") break print(i) print("Finished") It shows the output being "1 Skipping 2 3 4 Breaking Finished" Why are the last three lines not "Breaking 5 Finished" Where it shows print(i) after break?
clarification please?
3 Réponses
+ 3
"break" breaks the loop immediately even if "break" is inside "if/elif/else". You just exit the loop if you encounter "break". "print(i)" is inside the loop so it is not executed (you have exited the loop)
0
Ohhh right. That actually helped a lot. Thank you
0
please explain the whole code..I m not getting it..as u said continue will ignores the next statement and will go to the top of loop..so how it is printing 1