LearnPy Hub
← Context Managers problems
Easy

Which Error Reached __exit__?

Write a class Watch whose __exit__(self, exc_type, exc, tb) prints no error if exc_type is None, else the error's class name, and returns True (to swallow it). Inside with Watch(): run print(10 // int(line)).

Input

One line.

Output

One or two lines.

Sample 1

Input
2
Output
5
no error

Sample 2

Input
0
Output
ZeroDivisionError
solution.py
Output appears here
Which Error Reached __exit__? · Python practice problem · LearnPy Hub