Does anyone know why my code just suddenly stop passing all the test it passed before? It seems to be because of line 42 but i cant see what is wrong with it?
class Category:
def \__init_\_(self,name):
self.name = name
self.ledger = \[\]
def deposit(self,amount, description=""):
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=""):
if self.check_funds(amount):
self.ledger.append({"amount": -amount, "description": description})
return True
else:
return False
def get_balance(self):
balance = 0
for transaction in self.ledger:
balance += transaction\['amount'\]
return balance
def check_funds(self, amount):
return amount <= self.get_balance()
def transfer(self, amount, destination_category):
if self.check_funds(amount):
self.withdraw(amount, f"Transfer to {destination_category.name}")
destination_category.deposit(amount, f"Transfer from {self.name}")
return True
else:
return False
def \__str_\_(self):
listled = \[\]
num = 0
for item in self.ledger:
amount = item\["amount"\]
description = item\["description"\]
right_bit = 30 - len(description)
listled.append(f"{description:<0}{amount:>{right_bit}}")
num += 1
return f"{self.name.center(30, '\*')}\\n{'\\n'.join(listled)}\\nTotal: {self.get_balance()}"
