Python Try Finally
finally block, if specified, will be executed
regardless if the try block
raises an error or not.
print("Something went wrong")
print("The 'try except' is finished")
This can be useful to close objects and clean up resources:
Try to open and write to a file that is not writable:
f = open("demofile.txt")
print("Something went wrong when writing to the file")
The program can continue, without leaving the file object open.