Tell us what’s happening:
Hello, I am working on the budget app project . I received this ValueError and I don’t know what it mean. Can someone explain to me what this mean? I wrote my code just like the python string formatting shown below.
Your code so far
class Category:
def __init__(self, name):
self.name = name
self.amount = 0
self.ledger = []
def deposit(self, amount, description=''):
self.amount += amount
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=''):
if self.check_funds is False:
return False
else:
self.amount -= amount
self.ledger.append({"amount": amount * -1, "description": description})
return True
def get_balance(self):
return self.amount
def check_funds(self, amount):
get_balance_amount = self.get_balance()
if self.amount > get_balance_amount:
return True
else:
return False
def transfer(self, amount, category):
if self.check_funds(amount):
self.amount -= amount
self.ledger.append({"amount": amount * -1, "description": "[Destination Budget Category]"})
category.ledger.append({"amount": amount, "description": "[Source Budget Category]"})
def __str__(self):
title = self.name.center(30, "*") + "\n"
item = ''
for i in range(len(self.ledger)):
item += '{:.23}'.format('self.ledger[i]["description"]') + '{:>7.2f}'.format('self.ledger[i]["amount"]') + "\n"
total = self.get_balance()
output = title + item + "Total: " + str(total)
return output
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
.
Challenge: Budget App
Link to the challenge: