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.
class Category:
def __init__(self, name):
self.name = name
self.ledger = list()
def __str__(self):
title = f"{self.name: *^30}\n"
items = ""
total = 0
for items in self.ledger:
item +=f"{item['description'][0:23]:23}" + f"{item['amount']:>7.2f}" + "\n"
total += item ["amount"]
output= title + items + "Total: " + str(total)
return output
def deposit(self, amount, description=""):
"""A deposit method that accepts an amount and a description.
If no description is given, it should default to an empty string.
The method should append an object to the ledger list in the form
of {"amount" : amount, "description": description}
"""
self.ledger.append({"amount": amount, "description": description}