Build a Budget App - Build a Budget App

Tell us what’s happening:

on the Category class, I couldn’t check the ‘16. Printing a Category instance should give a different string representation of the object’ box. It prints exactly the same thing, but why is the code getting rejected??

Your code so far

class Category:
    def __init__(self, name):
        self.name = name
        self.ledger = []
    
    def deposit(self, amnt, description = ""):
        self.ledger.append({'amount': amnt, 'description': description})
    def withdraw(self, amnt, description = ""):
        lngth = len(self.ledger)
        if self.check_funds(amnt):
            self.ledger.append({'amount': -amnt, 'description': description})
            if len(self.ledger) == lngth + 1:
                return True
        else:
                return False
    def get_balance(self):
        sum_amnt = 0

        for i in self.ledger:
            sum_amnt += i['amount']
        return sum_amnt

    def transfer(self, amnt, category):
        len_ordr = [len(self.ledger), len(category.ledger)]
        if self.check_funds(amnt):
            withdraw_desc = f"Transfer to {category.name}"
            deposit_desc = f"Transfer from {self.name}"
            
            self.withdraw(amnt, withdraw_desc)
            category.deposit(amnt, deposit_desc)

            if len(self.ledger) == len_ordr[0] + 1 and len(category.ledger) == len_ordr[1] + 1:
                return True
        else:
                return False
    def check_funds(self, amnt):
        sum_amnt = self.get_balance()
        if amnt > sum_amnt:
            return False
        else:
            return True
    def __str__(self):
        sum_amnt = self.get_balance()
        ret_frm = f"{self.name:*^30}\n"
        for i in self.ledger:            
            ret_frm += f"{i['description']:<23}"
            ret_frm += f"{i['amount']:>7.2f}"
            ret_frm += "\n"            

        ret_frm += f"Total: {sum_amnt:.2f}"
        return ret_frm

def create_spend_chart(categories):
    pass

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Challenge Information:

Build a Budget App - Build a Budget App

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-budget-app/5e44413e903586ffb414c94e.md at main · freeCodeCamp/freeCodeCamp · GitHub

With the following test:

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)

I get this result:

*************Food*************
initial deposit        1000.00
groceries               -10.15
restaurant and more food for dessert -15.89
Transfer to Clothing    -50.00
Total: 923.96

But in the example in the instructions it says it should look like this

*************Food*************
initial deposit        1000.00
groceries               -10.15
restaurant and more foo -15.89
Transfer to Clothing    -50.00
Total: 923.96