Tell us what’s happening:
My code isn’t meeting these requirements “The transfer method should increase the balance of the category object passed as its argument.
The transfer method should create a specific ledger item in the category object passed as its argument.” and i have tried a bunch of different solutions, woukd really appreciate some insight.
Your code so far
def create_spend_chart(categories):
return None
class Category:
def __init__(self, name):
self.name = name
self.total = 0
self.ledger = []
def deposit(self, amount, description = ''):
self.total += amount
self.ledger.append({'amount': amount, 'description': description})
def withdraw(self, amount, description = ''):
if self.check_funds:
self.total -= amount
self.ledger.append({'amount': -amount, 'description': description})
return True
def get_balance(self):
return self.total
def transfer(self, amount, instance):
if self.check_funds:
self.total -= amount
self.ledger.append({'amount': -amount, 'description': 'Transfer to ' + instance.name})
return True
instance += amount
self.ledger.append({'amount': +amount, 'description': 'Transfer from ' + self.name})
return True
def check_funds(self, amount):
if amount <= self.total:
return True
else:
return False
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Challenge Information:
Build a Budget App Project - Build a Budget App Project