All projects
Advanced+110 XP
Bank Account
Build a BankAccount class that protects its balance. Withdrawing more than you have should raise a custom exception you catch with try/except. Combines OOP with error handling — a very real-world pattern.
Requirements
- 1
Create an
InsufficientFundsexception (subclass ofException) - 2
deposit(amount)increases the balance - 3
withdraw(amount)raisesInsufficientFundsif amount > balance - 4
Catch the exception with try/except and keep going
Build it here — edit the starter code and hit Run:
bank-account.py · editable