breakExpert Playground

Exits the nearest enclosing for or while loop immediately

Python Playground
Output
Click "Run" to execute your code

break compiles to JUMP_ABSOLUTE past the loop. When else is present, break jumps over the else block, while normal loop completion falls through to it.

Challenge

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