Tell us what’s happening:
I know this is a little early but why isn’t test case 6 getting checked off? It does exactly what it’s supposed to do? And also, what does it mean for example in test case 1 where it says that the deposit method should create a specific object in the ledger instance variable? Am I not appending an object into the ledger instance variable? These two things would really help me to continue.
Your code so far
current_balance = 0
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def deposit(self, amount, description = ""):
self.ledger.append(f"amount: {amount}")
self.ledger.append(f"description: {description}")
def withdraw(self,amount, description= ""):
global current_balance
#loops through the ledger list
for i in self.ledger:
#looks for the amount deposited
if "amount" in i:
#converts that amount to an integer
conversion = int(i[8:])
#Checks to see if withdrawal amount is possible
if amount <= conversion:
self.ledger.append(f"amount: -{amount}")
self.ledger.append(f"description: {description}")
current_balance = conversion - amount
return True
else:
return False
def __str__(self):
return str(current_balance)
def create_spend_chart(categories):
pass
food = Category("food")
food.deposit(900, 'deposit')
print(food.withdraw(45.67, 'milk, cereal, eggs, bacon, bread'))
print(food)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
Challenge Information:
Build a Budget App - Build a Budget App