Deposit Error -- Budget App

Tell us what’s happening:
It keeps giving me an error when I have successfully done the deposit part and it should pass the test for it. It also says there should be an index for it.

Your code so far

class Category:
  global name
  def __init__(self,name): = name
    self.ledger = []
  def deposit(self,amount,*descripton):
    global amountNumber
    global descStrDeposit
    if len(descripton) >= 1:
      amountNumber = amount
      descStrFix1 = str(descripton).replace('(','')
      descStrFix2 = descStrFix1.replace(')','')
      descStrFix3 = descStrFix2.replace(',','')
      descStr = descStrFix3.replace('\'','')
      descStrDeposit = descStr

  def withdraw(self,amount,*descripton):
    global descStrWithdraw
    global amountWithdraw
    descStrFix1 = str(descripton).replace('(','')
    descStrFix2 = descStrFix1.replace(')','')
    descStrFix3 = descStrFix2.replace(',','')
    descStrWithdraw = descStrFix3.replace('\'','')
    amountWithdraw = amount
  def get_balance(self):
    for i in range(len(
      starSpace = 30
      starSpace -= 1
    starSpaceHalf = starSpace / 2
    starSpaceHalf2 = starSpaceHalf
    while starSpaceHalf >= 2:
      starSpaceHalf -= 1
    while starSpaceHalf2 >= 2:
      starSpaceHalf2 -= 1
  def transfer(self,amount,category):

def create_spend_chart(categories):

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Budget App

Link to the challenge:

Thank you for creating this thread.
It would be better if you had provided a link to your code so I am just having a guess here.

  1. self.ledger is an array of dictionaries so only append elements enclosed in {}.

  2. You have so much unnecessary code inside your deposit function. What you really need is one line which appends a dictionary with “amount” and “description” as a key and its respective values.

  3. Remember that every tests relies on your self.ledger array to contain only dictionaries as elements.

ooooh so basicly im supposed to just append it? and here is the link -->
the project
and does that mean for the title i append it? thanks

do i append everything including the title or just the withdraw and deposit

    print (''.join(map(str, self.ledger)))

convert the above lines to =>

self.ledger.append({'amount':amount ,'description':description})

And also instead of *description in function description you can use description="" instead.
This means that by default description will be an empty string unless a value has been specified.

And in withdraw method you are supposed to append (amount * -1) and also make sure that you have enough money in your pocket before :wink: .
Good luck.

thanks you i am going to do that now

1 Like

I am giving a link to my code just in case you get stuck here forever. I suggest you not to see this until you solve your problem :smiley:.
** **

id rather work it out my self but thanks i was wondering can you elaborate on what a return does because i have seen many on stack overflow use it and i think it should help me on this but i dont understand what it does?

1 Like

oh nvm i looked on overflow and eventually found one but i seem to be stuck on the get_balance part like how do i find the balance after the withdraw do you mind explaining

1 Like