Extending Exception With Custom Message
Mon 10 August 2026
class AgeLimitError(Exception):
def __init__(self, age):
super().__init__(f"Age {age} is below allowed limit")
def validate_age(age):
if age < 18:
raise AgeLimitError(age)
validate_age(15)
Score: 5
Category: chapter7_custom_exceptions