Exception handling

How does try and catch block works?
Why is finally() keyword used?

The code within the try clause will be executed statement by statement.
If an exception occurs, the rest of the try block will be skipped and the except clause will be executed.

If you don’t specify an exception type on the except line, it will catch all exceptions.

A finally clause is always executed before leaving the try statement, whether an exception has occurred or not.

Hope this helps!