Skip to content

Commit 5e94a72

Browse files
Update other/bank_account.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1661ee0 commit 5e94a72

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

other/bank_account.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@ class BankAccount:
1919
130.0
2020
>>> account.account_number
2121
'ACC-1001'
22+
23+
>>> BankAccount("", initial_balance=10.0)
24+
Traceback (most recent call last):
25+
...
26+
ValueError: account_number must be provided
27+
28+
>>> BankAccount("ACC-1002", initial_balance=-1.0)
29+
Traceback (most recent call last):
30+
...
31+
ValueError: initial_balance cannot be negative
32+
33+
>>> account.deposit(0)
34+
Traceback (most recent call last):
35+
...
36+
ValueError: deposit amount must be positive
37+
38+
>>> account.withdraw(0)
39+
Traceback (most recent call last):
40+
...
41+
ValueError: withdraw amount must be positive
42+
43+
>>> account.withdraw(1000)
44+
Traceback (most recent call last):
45+
...
46+
ValueError: insufficient funds
2247
"""
2348

2449
def __init__(self, account_number: str, initial_balance: float = 0.0) -> None:

0 commit comments

Comments
 (0)