LearnPy Hub
← Context Managers problems
Hard

Inspect the Exception

Write a context manager whose __exit__ prints no error, or the exception type name and message as TYPE: MESSAGE, and swallows the exception. Inside, evaluate the input expression with eval and print the result.

Input

One Python expression.

Output

Lines.

Sample 1

Input
2 + 3
Output
5
no error

Sample 2

Input
1 / 0
Output
ZeroDivisionError: division by zero
solution.py
Output appears here
Inspect the Exception · Python practice problem · LearnPy Hub