LearnPy Hub
← Context Managers problems
Easy

__exit__ Runs After an Error

Write a class Guard whose __exit__ prints cleaned up and returns False. Inside with Guard(): do int(line) and print it. Catch any ValueError outside and print bad number.

Input

One line.

Output

Two lines.

Sample 1

Input
5
Output
5
cleaned up

Sample 2

Input
five
Output
cleaned up
bad number
solution.py
Output appears here
__exit__ Runs After an Error · Python practice problem · LearnPy Hub