Budget app scientific computing python

can anybody help me out with the particular situation where i am unable run my check_funds() function.![codesnippet|422x500]errorsnap|690x126

def withdraw(self,amount,description=''):
        if self.check_funds(amount)==False:
            self.ledger.append({'amount':-1*amount,'description':description})
            return True
        else: 
            return False
    def get_balance(self):
        total=0
        for i in self.ledger:
            total+=i['amount']
        return total              
    def transfer(self,amount,b_category):
        if self.check_funds(amount)==False:    
            self.ledger.append({'amount':-1*amount,'description':'Transfer to '+str(b_category.name_of())})
            b_category.deposit(amount,'Transfer from '+self.name)
            return True
        else:
            return False
    def check_funds(self,amount):
        balance=0
        for i in self.ledger:
            balance+=i['amount']
        if balance<amount:
            return True
        else:
            return False
        

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.

Challenge: Budget App

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

2 Likes
if balance<amount:
            return True

This should return false. You should return True when balance is greater than amount. I believe there’s a typo in the README.

thank you for the info on the backticks. it helped me posting my code! my first post. also having a problem with this project. have a good day :grinning:

Hello!

May I ask how you did your transfer() method? Specifically the line that adds to the receiving ledger 'Transfer from [Source budget category]'? I'm not entirely sure how to add in the name of the Instance as a variable. Any help would be greatly appreciated!

see first all i have done is simply add to the ledger where amount is received and secondly remove the entry of ledger from where the amount was transferred

the transfer takes in the amount and the object where the sum is to be transferred.For your reference see the snippet below.

```def transfer(self,amount,b_category): if self.check_funds(amount): self.ledger.append({'amount':-1*amount,'description':'Transfer to '+str(b_category.name_of())}) b_category.deposit(amount,'Transfer from '+self.name) return True else: return False```