Plenty of π
Module 3: Control Flow - Conditional Execution and Loops
Controlling Loop Execution: `break`, `continue`, and `else` in Loops
  • break: Immediately exits the current loop (both for and while).

  • continue: Skips the rest of the current iteration and proceeds to the next iteration of the loop.

  • else clause in loops: An optional else block can be used with loops. For a for loop, the else block executes after the loop finishes all iterations, but only if the loop was not terminated by a break statement. For a while loop, the else block executes when the loop's condition becomes False, but not if the loop was exited with break. Example with for: for i in range(3): print(i) else: print("Loop finished normally")