assert — Advanced Playground
Debugging aid that tests a condition and raises AssertionError if false
Python Playground
Output
Click "Run" to execute your codeThe most common assert pitfall is writing assert(cond, msg) with parentheses — this creates a non-empty tuple which is always truthy. Use assert cond, msg without parens.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?