Tell us what’s happening:
Why is it not giving me pass even if both methods are correct?
Your code so far
def __str__(self):
Title_line = ("*" * ((30 - len(self.name)) // 2)) + self.name + ("*" * ((30 - len(self.name)) // 2))
items = ""
for item in self.ledger:
desc = item["description"][:23].ljust(23)
amt = f"{item['amount']:.2f}".rjust(7)
items += desc + amt + "\n"
total = f"Total: {self.get_balance():.2f}"
return Title_line + items + total
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a Budget App - Build a Budget App
Your code isn’t passing because it isn’t correct.
Where did the starting code you were given to use go?
I deleted because it is not the one I want to mean, this is what I am talking: (“" * ((30 - len(self.name)) // 2)) + self.name + ("” * ((30 - len(self.name)) // 2)), it only give correct when: self.name.center(30, “*”) + “\n”
Please just look at the part I posted. Other parts I passed that is why I don’t show anymore.
Please share your full code so we can test it.
If you have a question, please ask?
Here are some troubleshooting steps you can follow. Focus on one test at a time:
- Are there any errors or messages in the console?
- What is the requirement of the first failing test?
- Check the related User Story and ensure it’s followed precisely.
- What line of code implements this?
- What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)
If this does not help you solve the problem, please reply with answers to these questions.
I mean both are correct: ("*" * ((30 - len(self.name)) // 2)) + self.name + ("*" * ((30 - len(self.name)) // 2)) and self.name.center(30, “*”) + “\n”, but they only give pass to self.name.center(30, “*”) + “\n”
Do those give the same output?
One seems to end in a newline and one doesn’t?
Please provide all of the code, otherwise I cannot test your code
If two different expressions give two different outputs, then it is unlikely that both are correct
No. Both give the same output, but they only give pass to one of the method.
But they do not give the same output. Whitespace (newline characters) matters!
Oh, Thank you, I though it could work 