Tell us what’s happening:
hello I only need help with Test 1 and Test 2 to do with
The deposit method should create a specific object in the ledger instance variable
and
calling the deposit method with no description should create a blank description
all other issues I’ll be able to understand once i know why my logic isn’t working.
Your code so far
class Category:
def __init__(self,name):
self.name = name
self.ledger = []
self.balance = 0
def __str__(self):
no = len(self.name)
no_stars = round((30 - no)/2)
stars= '*'*no_stars
print(f'{stars}{self.name}{stars}')
def deposit(self,amount,description=''):
self.ledger.append(f"'amount': {amount}, 'description': {description}")
self.balance+= amount
def withdraw(self,amount,description=''):
if amount <= self.balance:
self.ledger.append(f"'amount': {-amount}, 'description': {description}")
self.balance-= amount
return True
else:
return False
def get_balance(self):
self.balance()
def transfer(self,amount,destination):
if amount <= self.balance:
print(f'Transfer to {destination.name}')
self.balance-= amount
#transfer_to = Category(self,amount,destination)
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')
food.withdraw(10.15, 'groceries')
food.withdraw(15.89, 'restaurant and more food for dessert')
clothing = Category('Clothing')
food.transfer(50, clothing)
print(food.deposit)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Challenge Information:
Build a Budget App - Build a Budget App