Build a Budget App - Build a Budget App

Tell us what’s happening:

I can’t pass the 3rd test on the ‘Build a Budget App’ in the python course.

I am not sure how the ledger is supposed to work. I thought it’s supposed to be a list of dictionaries of the form {‘amount’: amount, ‘description’: description}, but it doesn’t seem to pass the test. I’ve also tried just appending -amount every time, but it doesn’t work either.

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):
            self.ledger.append({'amount': -amount, 'description': description})
            return True
        else:
            return False

    def check_funds(self, amount):
        return self.get_balance>=amount

    def get_balance(self):
        self.balance=0
        for dictionary in self.ledger:
            self.balance+=dictionary['amount']
        return self.balance

    def transfer(self, amount, category):
        if self.check_funds(amount):
            self.withdraw(amount, f'Transfer to {category}')
            category.deposit(amount, f'Transfer from {self.name}')
            return True
        else:
            return False

#food=Category('food')
#food.deposit(900, 'deposit')
#food.withdraw(45.67, 'milk, cereal, #eggs, bacon, bread')
#print(food)


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 Edg/149.0.0.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

Welcome to the forum @Matt2,

If I uncomment this code, I see an error in the console:

  File "main.py", line 11, in withdraw
  File "main.py", line 18, in check_funds
TypeError: '>=' not supported between instances of 'method' and 'float'

Are you referencing self.get_balance correctly on Line 18? Is it an instance variable or a method?

Happy coding

You’re right. I needed to write self.get_balance() . I guess I thought the parenthesis are optional if the method doesn’t take any variables. Maybe I didn’t understand the lessons that well after all.

Hi, I’m not sure if this is the right thread to raise my issue. I’m also working on the Budget App and I’m stuck on test 19. I think the console shows the correct bar height. The first category percentage computes to 60.33, the second 23.80 and the third is 15.86. The bar for the first ‘o’ from 60 to 0, the second from 20 to 0 and the third from 10 to 0. I’m sending a screenshot of the console. Thank you

Welcome to the forum @jun.dolor,

Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.

The easiest way to create a topic for help with your own solution is to click the Help button image located on each challenge. This will automatically import your code in a readable format and pull in the challenge URL while still allowing you to ask any question about the challenge or your code.

Thank you.