""" Exercise 7.2 from "A primer on..." Add an attribute to the Account class, which counts the number of transactions for the account. Adapt the dump-method to print the number of transactions in addition to the other info. """ class Account: def __init__(self, name, account_number, initial_amount): self.name = name self.no = account_number self.balance = initial_amount self.transactions = 1 def deposit(self, amount): self.balance += amount self.transactions += 1 def withdraw(self, amount): self.balance -= amount self.transactions += 1 def dump(self): s = f"{self.name}, {self.no} balance: {self.balance}, transactions: {self.transactions}" print(s) a1 = Account('John Olsson', '19371554951', 20000) a2 = Account('Liz Olsson', '19371564761', 20000) a1.deposit(1000) a1.withdraw(4000) a2.withdraw(10500) a1.withdraw(3500) print('a1 balance:', a1.balance) a1.dump() a2.dump() """ Terminal> python Account2.py a1 balance: 13500 John Olsson, 19371554951 balance: 13500, transactions: 4 Liz Olsson, 19371564761 balance: 9500, transactions: 2 """