Hello:
Any tips would be most helpful.
I’ve been wrangling with this problem for awhile, I continue to get the error shown below my code. I’ve tried using category.name, category, etc. but nothing eliminates the “attribute error” on line 29 in the transfer method. I’m able to withdraw find, but not deposit.
https://replit.com/@EdwardakaLarrya/boilerplate-budget-app-1#budget.py
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def __str__(self):
return str(self.name)
def deposit(self, amount, description=''):
self.ledger.append({"amount": amount, "description": description.__str__()})
def get_balance(self):
self.balance = 0
for item in self.ledger:
self.balance += item["amount"]
return self.balance
def withdraw(self, amount, description=''):
if self.check_funds(amount) is True:
return self.ledger.append({"amount": (amount *- 1), "description": description.__str__()})
else:
return False
def transfer(self, amount, category):
tf_desc = str("Transfer from " + str(self))
tt_desc = str("Transfer to " + category.__str__())
self.withdraw(amount, str(tf_desc))
category.name.deposit(amount, tt_desc.__str__())
def check_funds(self, amount):
self.balance = 0
for item in self.ledger:
self.balance += item["amount"]
print(self.balance)
if self.balance < abs(amount):
return False
else:
return True
def create_spend_chart(*args):
pass```
Traceback (most recent call last):
File “main.py”, line 12, in
food.transfer(50, clothing)
File “/home/runner/boilerplate-budget-app-1/budget.py”, line 29, in transfer
category.name.deposit(amount, tt_desc.str())
AttributeError: ‘str’ object has no attribute ‘deposit’
exit status 1```