finally — Easy Playground
Block that always executes after try/except, used for cleanup
Python Playground
Output
Click "Run" to execute your codefinally always executes, whether the try block succeeds, raises an exception, or returns. Use it for cleanup like closing files or releasing locks.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?