Learn Error and Exception Handling in Python with Detail Explanation

Error and Exception handling in Python are mechanisms to handle unexpected errors that may occur in the program during runtime.

1. Mismatched Input 2. File does not exist 3. Divide by zero        exception 4. IndentationError

try-except block is used to handle errors or exceptions in python.

This is the Syntax of try-except block

Output:-  Error: Index out of range

else: when there is no exception in try block then else block is run.

finally: finally block is always run even if there is an error or not.

This is the Example with else and finally block

Output of the previous Example