Quiz · Exceptions · lesson 9 of 11Quiz — a custom exceptionHow do you define a custom exception in Python?[A]Python code does not define new exceptions: raise accepts the built-in classes such as ValueError or KeyError, and a class you write yourself, even one based on Exception, is rejected with an error.[B]Subclass BaseException directly, since Exception is meant for built-in errors. Keeping your exceptions outside Exception means an ordinary except Exception branch does not catch your custom error by accident.[C]Subclass Exception (not BaseException), conventionally naming it with an Error suffix. You may add attributes or a custom __init__ to carry data. Then raise MyError("msg") like any built-in exception.[D]Subclass Exception and use it as a bare marker: a custom exception carries no message or attributes, so MyError("msg") raises a TypeError and you raise the bare class instead.Subscribe to take the courseThe course is free. Sign in with Telegram and subscribe to the channel to open every lesson.Continue with TelegramSign in another way← BackCustom exceptionsNext →Exercise: a safe int