hwoto neglect if any exception happening in python 1

hwoto neglect if any exception happening in python

try:
    print(invalid-variable)
except Exception:
    pass

print("Exception ignored")
OUTPUT

Here is what the above code is Doing:
1. We define a function that raises an exception.
2. We call the function and catch the exception.
3. We print a message to the user.

The try block lets you test a block of code for errors.
The except block lets you handle the error.
The finally block lets you execute code, regardless of the result of the try- and except blocks.

Similar Posts