Skip to main content

Practice · 1 of 2

Session Tracker

CHALLENGE
Difficulty: intermediate+25 XP

Create a class Session with __enter__ returning the string 'open' and appending 'open' to a module-level list EVENTS; __exit__ appends 'closed' and returns False. After a with block, EVENTS must be ['open', 'closed'] even if the body raises.

Back to lesson: Practice: Context Manager Drills