Objective
Create a Python program with a custom exception to control withdrawals of money from an account.
Instructions
- Create the class
InsufficientFundsError, which inherits fromException. Its message isInsufficient funds: missing N, whereNis the money that is missing. - Create the class
Accountwith the attributebalanceand the methodwithdraw(amount), which raises the exception if the amount is greater than the balance and, otherwise, subtracts the amount. - Read the initial balance and the amount to withdraw (integers).
- If the withdrawal is made, show
New balance: X. If the exception is raised, show its message.
100
30
New balance: 70
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise