Tell us what’s happening:
Hi everyone,
I struggle with task 4/16 of the exercise.
My main problem is that I don’t know the necessary comands. Are there a solution with the commands we learnd in the course so far? Or are we encouraed here to look them up outside the course in other forums etc.?
If someone mind, it would be very helpful if you guys could tell me where I find the instructions in the course for this task. I tried to find them in the previous lessons but wasn’t successful.
Thanks in advance!
Your code so far
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def deposit(self, amount, description=""):
self.amount = amount
self.description = description
self.ledger.append({'amount': self.amount, 'description': self.description})
def withdraw(self, amount, description=""):
self.amount = amount
self.description = description
self.ledger.append({'amount': -self.amount, 'description': self.description})
if self.check_funds(amount) == True and {'amount': -self.amount, 'description': self.description} in self.ledger:
return True
else:
return False
def get_balance(self):
return sum(item["amount"] for item in self.ledger)
#food = Category('name')
#food.deposit(900, 'deposit')
#print(food.withdraw(45.68, 'milk, cereal, eggs, bacon, bread'))
#print(food.get_balance)
def transfer(self, amount, destination):
self.amount = amount
self.destination = destination
if self.check_funds(amount) == True and self.withdraw(amount, f'Transfer to {destination.name}'):
destination.deposit(amount, f'Transfer from {self.name}')
return True
else:
return False
def check_funds(self, amount):
if self.get_balance() < amount or amount > self.get_balance():
return False
else:
return True
def __repr__(self):
print(self.name.center({self.name}, 30))
print(item for item in self.ledger(amount, description = ""))
print(f'\nTotal: [{self.get_balance}]')
def create_spend_chart(categories):
pass
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0
Challenge Information:
Build a Budget App - Build a Budget App