Back to search

Loop control with break, continue, pass, and loop else

`break` stops a loop, `continue` skips to the next iteration, `pass` is a placeholder, and loop `else` runs only if the loop did not break.

Python Medium Theory

Loop control with break, continue, pass, and loop else

`break` stops a loop, `continue` skips to the next iteration, `pass` is a placeholder, and loop `else` runs only if the loop did not break.

  • Loop else is lesser known
  • break changes whether else runs
  • pass does nothing by itself

Loop control with break, continue, pass, and loop else