Budget App Help

Hey there,

I have a feeling this is something really silly but for the life of me, I can’t figure out the issue.

I’m making these calls to run some quick tests on my code.
It’s telling me withdraw() takes 0 arguments when I’ve defined the arguments it should take.

I’m stomped :frowning:

food = budget.Category("Food")
food.deposit(1000, "initial deposit")
food.withdraw(10.15, "groceries")
food.withdraw(15.89, "restaurant and more food for dessert")

budget.py file:

class Category:

  def __init__(self, category):
    self.name = category
    self.ledger = []
    self.total_amount = 0
    self.withdraw_amount = 0

  def check_funds(self, amount):
    print('in check_funds')
    if amount > self.total_amount:
      return True
    return False

  def deposit(self, amount, description=None):
    if description is None:
      deposit_item = {"amount": amount, "description": ''}
      self.total_amount += amount
       deposit_item = {"amount": amount, "description": description}
       self.total_amount += amount

  def withdraw(self, amount, description=None):
    check = self.check_funds(amount)

Error I’m getting:

check_funds() takes 0 positional arguments but 2 were given

There must be another issue in your code.
I can copy the check_funds into my project and it works - except that your condition is wrong :wink:

1 Like

OMG! :man_facepalming:

I declared the function twice! The first declaration was me setting up the structure for everything and how I thought I should go about it. (forgot I did this)

The second declaration was when I actually wrote the code.

After reading your reply, I found this in the bottom of my file :weary::

  def check_funds():
      A `check_funds` method that accepts an amount as an argument. It returns `False` if the amount is greater than the balance of the budget category and returns `True` otherwise. This method should be used by both the `withdraw` method and `transfer` method.

Thank you!! :pray: