Methods in exceptions

Report a typo

Have a look at the code. The X method returns a message with an error. What is the correct function name instead of X?

class LessThanError(Exception):
    def X(self):
        return 'There is an error!'


x = 100
if x < 101:
    raise LessThanError
# Traceback (most recent call last):
#   File "main.py", line 7, in <module> 
#     raise LessThanError
# LessThanError: There is an error!
Enter a short text
___

Create a free account to access the full topic