LearnPy Hub
← Context Managers problems
Medium

Clean-up After an Error

Write a context manager that prints setup on entry and cleanup on exit, even on errors. Inside, convert the input to int and print it doubled. Catch ValueError outside the with and print bad input.

Input

One line.

Output

Lines.

Sample 1

Input
21
Output
setup
42
cleanup

Sample 2

Input
abc
Output
setup
cleanup
bad input
solution.py
Output appears here
Clean-up After an Error · Python practice problem · LearnPy Hub