Home / Challenges / Bank Account Class

Bank Account Class

Hard
Create a BankAccount class with:

Attributes:
- owner (str)
- balance (float, default 0)
- transactions (list)

Methods:
- deposit(amount): Add money, record transaction
- withdraw(amount): Remove money (raise ValueError if insufficient funds)
- get_balance(): Return current balance
- get_statement(): Print all transactions

Raise ValueError for negative amounts.

Input

Owner name, optional initial balance

Output

Working BankAccount object

Example

Input
acc = BankAccount("Alice", 1000)
acc.deposit(500)
acc.withdraw(200)
Output
Balance: 1300
⚡ 30 XP on solve ← Back to lesson

Your Solution

Output
Click "Run" to execute your code...

Log in to submit your solution and earn XP.