Build a Budget App - Build a Budget App

Tell us what’s happening:

Test 16 keeps failing even though my method returns the correct string. please help

Your code so far

class Category:
    def __init__(self, name):
        self.name=name
        self.ledger=[]

    def deposit(self, amount, description=""):
        self.ledger.append({'amount': amount, 'description': description})
    
    def withdraw(self, amount, description=""):
        if self.check_funds(amount):
            negative_amount=amount*-1
            self.ledger.append({'amount': negative_amount, 'description': description})
            return True
        else:
            return False
    
    def get_balance(self):
        balance = 0
        for transaction in self.ledger:
            balance += transaction['amount']    
        return balance
    
    def transfer(self, amount, destination):
        if self.check_funds(amount):
            self.ledger.append({'amount':-amount, 'description': f"Transfer to {destination.name}"})
            destination.ledger.append({'amount': amount, 'description': f"Transfer from {self.name}"})
            return True
        else:
            return False
    
    def check_funds(self, amount):
        if amount>self.get_balance():
            return False
        else: 
            return True

    def __str__(self):
        asterisk_number=(30-len(self.name))//2
        asterisk_string="*"*asterisk_number
        result = (f"{asterisk_string}{self.name}{asterisk_string}\n")
        
        for transaction in self.ledger:
            description=transaction['description']
            amount_str=str(round(transaction['amount'], 2))
            if len(description)>23:
                description=description[:23]
            if len(amount_str)>7:
                amount_str=amount_str[:7]
            space_number=30-((len(amount_str))+(len(description)))
            space_string=" "*space_number
            result += f"{description}{space_string}{amount_str}\n"
            
        result+=f"Total: {str(self.get_balance())}\n"
        
        return result
    
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)




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/148.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

Welcome to the forum @altpaul295

Transfer to Clothing    -50.00

Shouldn’t all the prices have two decimal places?

Happy coding