Tell us what’s happening:
Not sure why I’m stumped so hard on test 7, must be misinterpreting something because from my test prints on the ledger in the target category, the methods up to here all work as expected. Yet despite the console showing the new ledger added, I’m still getting that the transfer method isnt creating one. Appreciate some help on this!
Also it’s driving me and from the looks of it, many others crazy that there are so few exercises along the way and hints are almost comically and excessively vague.
Your code so far
class Category:
def __init__(self,name):
self.name=name
self.ledger=[]
self.balance=0
def deposit(self,amount,description=''):
self.balance+=amount
self.ledger.append({'amount': amount, 'description': description})
def withdraw(self,amount,description=''):
if self.check_funds(amount):
self.balance+=amount*-1
self.ledger.append({'amount': amount*-1, 'description': description})
return True
else:
return False
def get_balance(self):
return self.balance
def transfer(self,amount,destination):
if self.check_funds(amount):
self.withdraw(amount,description=f'Transfer to {destination}')
destination.deposit(amount,f'Transfer from {self.name}')
return True
else:
return False
def check_funds(self,amount):
if amount>self.balance:
return False
else:
return True
def create_spend_chart(categories):
pass
food = Category('Food')
food.deposit(1000, 'initial deposit')
print(food.get_balance())
clothes = Category('Clothes')
clothes.deposit(500, 'initial deposit')
print(clothes.get_balance())
food.transfer(100,clothes)
print(food.get_balance())
print(clothes.get_balance())
print(clothes.ledger)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Challenge Information:
Build a Budget App - Build a Budget App