exceptExpert Playground

Catches and handles exceptions raised in a try block

Python Playground
Output
Click "Run" to execute your code

except compiles to CHECK_EXC_MATCH which uses isinstance() to test exception types. Multiple types in a tuple are checked sequentially. The 'as' binding stores the exception in a local variable that is deleted when the except block exits.

Challenge

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