Adv Py Theory
Adv Py Theory
● Python has many built-in exceptions that are raised when your
program encounters an error.When these exceptions occur, the
Python interpreter stops the current process and passes it to the
calling process until it is handled. If not handled, the program will
crash.
Output
Finally clause - When we handle exception using the try and except block,
we can include a finally block at the end. The finally block is always
executed, so it is generally used for doing the concluding tasks like closing
file resources or closing database connection or may be ending the
program execution with a delightful message.finally block is in a function
which returns a value.
Syntax
Output 1
Output 2