with — Easy Playground
Wraps a block with a context manager for automatic setup/teardown
Python Playground
Output
Click "Run" to execute your code'with' calls __enter__ at the start and __exit__ at the end, guaranteeing cleanup even if exceptions occur.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?