of courseif we do want to customize the initializerwe are free to do so here' an exception whose initializer accepts the current balance and the amount the user wanted to withdraw in additionit adds method to calculate how overdrawn the request wasclass invalidwithdrawal(exception)def __init__(selfbalanceamount)super(__init__("account doesn' have ${}formatamount)self amount amount self balance balance def overage(self)return self amount self balance raise invalidwithdrawal( the raise statement at the end illustrates how to construct this exception as you can seewe can do anything with an exception that we would do with other objects we could catch an exception and pass it around as working objectalthough it is more common to include reference to the working object as an attribute on an exception and pass that around instead here' how we would handle an invalidwithdrawal exception if one was raisedtryraise invalidwithdrawal( except invalidwithdrawal as eprint(" ' sorrybut your withdrawal is "more than your balance by "${}format( overage())here we see valid use of the as keyword by conventionmost python coders name the exception variable ealthoughas usualyou are free to call it exexceptionor aunt_sally if you prefer there are many reasons for defining our own exceptions it is often useful to add information to the exception or log it in some way but the utility of custom exceptions truly comes to light when creating frameworklibraryor api that is intended for access by other programmers in that casebe careful to ensure your code is raising exceptions that make sense to the client programmer they should be easy to handle and clearly describe what went on the client programmer should easily see how to fix the error (if it reflects bug in their codeor handle the exception (if it' situation they need to be made aware of