Lecture 41: Break and continue syntax structures in Python loop statements

1. The difference between break and continue

To end the loop in a while or for-in loop statement, in addition to using break to jump out of the loop, you can also use the continue statement.

The difference between break and continue:

  • break is used to end the entire loop.
  • continue is used to jump out of this loop and enter the next loop.

2. Demonstrate the difference between break and continue through a set of cases

Requirements: Traverse all elements in the sequence, and jump out of the loop if the element is K8S.

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/130573248