Why does the usage of the withdraw function (in the if statement in the transfer function) make an error saying the function is undefined?
class Category:
def __init__(self, name):
self.ledger = []
self.cat_name = name
self.balance = 0
def deposit(self, amount, description=""):
self.balance += amount
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=""):
if self.balance - amount >= 0:
self.balance -= amount
self.ledger.append({"amount": -1 * amount, "description": description})
return True
return False
def get_balance(self):
return self.balance
def transfer(self, newcat, ammount):
if(withdraw(amount, "Transfer to " + newcat.cat_name)):