Scientific Computing with Python Projects - Budget App

Tell us what’s happening:
when I call ‘transfer’ method, I get error like this…

Traceback (most recent call last):
File “C:\Users\visha\Desktop\Python\budget.py”, line 69, in
food.transfer(200,‘clothing’)
File “C:\Users\visha\Desktop\Python\budget.py”, line 39, in transfer
descrip.deposit(amt, f"Transfer from {self.category}")
AttributeError: ‘str’ object has no attribute ‘deposit’

because of this error I am able to add ‘Transfer to [Category]’ entry, but not able to make entry in the Category where I am transferring.

Your code so far
def transfer(self,amt = 0.0,descrip = ‘’):
if Category.check_funds(self,self.amount) == True:
self.withdraw(amt,('Transfer to '+ descrip))
descrip.deposit(amt, f"Transfer from {self.category}")
# Category(self.category).ledger.append({“amount”: (amt), “description”: 'Transfer from ’ + self.category})
# self.ledger.append({“amount”: -(amt), “description”: transfer_category})
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/107.0.0.0 Safari/537.36

Challenge: Scientific Computing with Python Projects - Budget App

Link to the challenge:

Please format your code in this way.

Your error

is telling you to look at this bit of your code

Why do you use self.withdraw() then descrip.deposit(), especially since you said descrip should default to the empty string in your function definition (def transfer(self,amt = 0.0,descrip = ‘’))?

Strings don’t have a deposit method. That would be part of the class you are defining for the project.

Also, either format with code blocks as previously mentioned or place your code in a repl (preferably replit.com) and post a link to make it easier for people to help.

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