breakIntermediate Playground

Exits the nearest enclosing for or while loop immediately

Python Playground
Output
Click "Run" to execute your code

The else clause of a for loop runs only when the loop finishes without hitting break. This is a clean search pattern.

Challenge

Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?