LearnPy Hub
← Context Managers problems
Easy

Enter and Exit

Write a class context manager Box(name) whose __enter__ prints open NAME and returns itself, and whose __exit__ prints close NAME. Inside the block print inside NAME.

Input

One word.

Output

Three lines.

Sample 1

Input
gift
Output
open gift
inside gift
close gift

Sample 2

Input
A
Output
open A
inside A
close A
solution.py
Output appears here
Enter and Exit · Python practice problem · LearnPy Hub