class Account:
def __init__(self):
self.balance = 0
def __repr__(self):
return f'<Account: {self.balance}>'
In [2]: from account import Account
In [3]: a = Account()
In [4]: a
Out[4]: <Account: 0>
class Account:
def __init__(self):
self.transactions = []
def __repr__(self):
return f'<Account: {self.balance}>
class Account:
def __init__(self):
self.transactions = []
def deposit(self, amount):
transaction = ('deposit', amount)
self.transactions.append(transaction)
def __repr__(self):
return f'<Account: {self.balance}>'
class Account:
def __init__(self):
self.transactions = []
def deposit(self, amount):
transaction = ('deposit', amount)
self.transactions.append(transaction)
def withdraw(self, amount):
transaction = ('withdraw', amount)
self.transactions.append(transaction)
def __repr__(self):
return f'<Account: {len(self.transactions)}>'
In [4]: a.transactions
Out[4]: []
In [5]: a.deposit(10)
In [6]: a.transactions
Out[6]: [('deposit', 10)]
Top comments (0)