Issue with Project 3 of Scientific Computing with Python

I am working on the budget app project of the Scientific Computing with Python. When I create multiple instances of the category class and call the withdraw() or deposit() method for one of them, the ledger instance variable is updated for every object, but this doesn’t happen for other instance variables like balance. I understand what is happening but I don’t know why this is only happening to one variable or how to fix it. Here is the link for my GitHub repo.

I can see the first lines of your class:

class Category:
    ledger = []
    balance = 0
    
    def __init__(self, category):
        self.category = category

but later you refer to self.leger. Why did you declare category, ledger and balance differently like this?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.