Using Break and Continue
In this lesson you’ll see practical examples of the two loop interruption options you’ve learned about in the last lesson. The used examples are debugged in the video, so that you get a sense of what’s happening behind the scenes. The examples covered in this lesson are displayed below.
n = 5 while n > 0: n = n - 1 if n == 2: break print(n) print("Loop is finished")
n = 5 while n > 0: n = n - 1 if n == 2: continue print(n) print("Loop is finished")
Comments & Discussion
Become a Member to join the conversation.