We have created the exception class called NotInBoundsError:
class NotInBoundsError(Exception):
def __str__(self):
return "There is an error!"
It prints an error message. The class is already defined in the code, so you can use it.
First, create the function check_integer(num) that checks if the given integer lies between 45 and 67. If it does, the function should return the integer. If not, the NotInBoundsError should be raised.
Second, create a new function error_handling(num). It should call the check_integer(num) function and use the try-except block to catch the NotInBoundsError. If there is an error, print its error message. If there are no errors, print the result of the check_integer(num) function.