Tell us what’s happening:
Hi, facing some trouble with the Budget App project. My print of the objects seems to be exactly similar to the output however, the test case still fails (printing object instance).
My understanding is the amounts are printed right after the descriptions, and then right aligned? Any guidance on where Im going wrong would be appreciated.
Your code so far
def __str__(self):
str_f=""
length=30-len(self.category)
str_f+=("*"*(length//2)) + self.category+("*"*(length//2)) +"\n"
#string formatting
max_num=0
max_amnt=0
for key in self.ledger:
if len(key["description"][:23])>max_num:
max_num=len(key["description"][:23])
if len(f'{key["amount"]:.2f}')>max_amnt:
max_amnt=len(f'{key["amount"]:.2f}')
for item in self.ledger:
str_f+=item['description'][:23]
amt=f'{item["amount"]:.2f}'
length=len(item['description'][:23])
str_f+=(amt).rjust((max_num+max_amnt)-(length))+'\n'
str_f+=f"Total: {self.get_balance()}"
return str_f
def create_spend_chart(categories):
pass
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Challenge Information:
Build a Budget App Project - Build a Budget App Project
