Hard
Cleanup Even on Errors
Write a generator-based context manager
step(name) that prints enter NAME, yields inside try, and in finally prints exit NAME. Nest three steps named from the input. Inside the innermost, divide 10 by the given number and print the result as an integer (//). Catch ZeroDivisionError outside all of them and print caught.Input
Three names on one line; then a number.
Output
Lines.
Sample 1
Input
a b c 2
Output
enter a enter b enter c 5 exit c exit b exit a
Sample 2
Input
x y z 0
Output
enter x enter y enter z exit z exit y exit x caught
Output appears here