LearnPy Hub
← Context Managers problems
Easy

Enter Returns a List

Write a class Basket whose __enter__ returns an empty list and whose __exit__ prints basket closed. Inside with Basket() as b: append each input word. After the block print the list.

Input

Words separated by spaces.

Output

Two lines.

Sample 1

Input
apple mango
Output
basket closed
['apple', 'mango']

Sample 2

Input
rice
Output
basket closed
['rice']
solution.py
Output appears here
Enter Returns a List · Python practice problem · LearnPy Hub