assert — Expert Playground
Debugging aid that tests a condition and raises AssertionError if false
Python Playground
Output
Click "Run" to execute your codeassert compiles to a conditional that loads AssertionError and raises it. When Python runs with -O flag, __debug__ is False and all assert statements are stripped from the bytecode entirely.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?