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
Output appears here