Build a budget app

class Category:
    
    def __init__(self,category):
        self.category = category
        ledger = ['']
        self.ledger = ledger
        print("1",ledger)
        print(category,'2',ledger)
    def deposit(self,amount,description = ''):
        self.description = description
        self.amount = amount
        print("3",amount)
        self.amount = amount
        print("4",amount)
        budget = amount
        print("5",budget)
        ledger.append({"amount": amount, "description": description})
        print("6",ledger)
        print(ledger)
        
    def check_funds(self,budget,amount):
        print("7")
        if amount-self.budget > 0:
            print("8")
            return True
        else:
            print("9")
            return False
    def withdraw(self,check_funds,category,description):
        print("10")
        if self.check_funds == True:
            ledger.append({"amount": '-' + amount, "description": description})
            print("11")
            return True
        else:
            print("12")
            return False
    def transfer():
        pass
    def get_balance():
        pass
def create_spend_chart():
    pass
    
food = Category("Food")
food.deposit(1000, "deposit")
food.withdraw(10.15, "groceries")
food.withdraw(15.89, "restaurant and more food for dessert")
clothing = Category("Clothing")
food.transfer(50, clothing)
food.deposit(900, "deposit") and food.withdraw(45.67, "milk, cereal, eggs, bacon, bread")

getting an AttributeError, it’s not recognizing deposit is there. i checked the console and its saying an error was raised before any tests could run. any suggestions?

fix your indentetion, the deposit method is inside the __init__ method

fixed that its complaining about ledger now.

you need to always use self for properties

Thats what ‘self.ledger = ledger’ is supposed to do.

so what’s this line then?

um… it’s to append amount and description on to ledger? what are you trying to ask about?

ledger doesn’t exist, you always need to use self to use attributes of the instance. Here you are not doing it. The traceback will point to the line, you may notice it is that line.

budget = 1000
amount = 100.15
print(budget-amount)
#if amount-budget <= 0:
#    print("8")
#else:
#    print("9")

def check_funds(budget,amount):
        print("7")
        if amount-budget <= 0:
            print("8")
            return True
        else:
            print("9")
            return False

i narrowed down the problem I’m having to the check_funds function, can’t figure out why it will not run

Can you please provide us with some more context? What are you solving, is it a challenge, if so post the link.

BTW, you are not running the function.

what do you mean by i am not running the function?