Build a Budget App - Build a Budget App

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

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-budget-app/5e44413e903586ffb414c94e.md

yes you can solve this with what is present so far in the curriculum

add the example code below your code

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)

you will see output in the terminal saying there are things wrong and you need to work on that

if you need an hint, when you use __repr__ or __str__ you need to give them a return value