Python finally Keyword
The finally block will always be executed, no matter if the try block raises an error or not:
x > 3
print("Something went wrong")
print("Nothing went wrong")
print("The try...except block is finished")
Definition and Usage
finally keyword is used in try...except
blocks. It defines a block of code to run when the try...except...else block is
finally block will be executed no matter
if the try block raises an error or not.
This can be useful to close objects and clean up resources.