Hi there,
I'm trying to create a class with whats below.
I made it and it works but i need to be able to withdraw an amount from the balance.
I'm just having trouble with the layout and whether i got the right idea?
Is the underlined area on the right track?
class BankAccount:
def __init__(self, balance, interestrate, accountnumber):
self.balance = balance
self.interestrate = interestrate
self.accountnumber = accountnumber
[B][U]def withdraw(self, amount):[/U][/B]
[B][U]self.amount = self.balance-self.amount[/U][/B]
p1 = BankAccount(5500, 0.2, 001)
Because when i type: p1.withdraw(500)
(i'm wanting to withdraw 500 from the balance of 5500.)
i get the error message:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in ?
p1.withdraw(500)
File "H:\Year 2\217CR James S\Lab 1\BankAccount.py", line 7, in withdraw
self.amount = self.balance-self.amount
AttributeError: BankAccount instance has no attribute 'amount'
Thanks in advance