I keep getting a FAIL: test_arrangement (test_module.UnitTests)

Tell us what’s happening:
one last failure, i dont understand what is required, please can anyone help?

``````        def arithmetic_arranger(problems, sn = True):
topLine = ''
buttomLine = ''
underLine = ''

total = 0
arranged_problems = ''
operand = ''
if len(problems) > 5:
return 'Error: Too many problems.'
for problem in problems:
spliting = problem.split()
numerator = spliting[0]
operand = spliting[1]
denumerator = spliting[2]

if len(numerator) > 4:
return "Error: Numbers cannot be more than four digits."
if len(denumerator) > 4:
return "Error: Numbers cannot be more than four digits."
if not numerator.isnumeric() or not denumerator.isnumeric():
return "Error: Numbers must only contain digits."
if operand == '+' or operand == '-':
if operand == '+':
total = str(int(numerator) + int(denumerator))
elif operand == '-':
total = str(int(numerator) - int(denumerator))
else:
return "Error: Operator must be '+' or '-'."

length = max(len(numerator), len(denumerator)) + 2
if problem != problems[-1]:
topLine += numerator.rjust(length) + '    '
buttomLine += operand + denumerator.rjust(length - 1) + '    '
underLine += "-" * length + '    '
answer += str(total).rjust(length) + '    '
else:
topLine += numerator.rjust(length)
buttomLine += operand + denumerator.rjust(length - 1)
underLine += "-" * length
if sn:
else:
arranged_problems = F"{topLine}\n{buttomLine}\n{underLine}"
return arranged_problems
``````

User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36`.

Challenge: Arithmetic Formatter

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hello~!

Could you provide the link to your `repl.it` or other live instance of this project? It is much easier to debug when we can run the code and view the error messages.

1 Like

Thank you - I’ll take a look now!

By the way, I edited your post to suppress the repl.it live embed - it appears it was not rendering correctly. Nothing you did wrong at all, but wanted to let you know that’s why I edited.

1 Like

Okay, these error messages are notoriously hard to interpret. But:

This shows me that you have an extra `-` at the end of your last problem there.

1 Like

okay thanks, let me try and fix that

1 Like

can not find a way around it, my dashes are generated by `underLine += "-" * (length)` this line of code for the last one reducing the dashes pops up a new fail…

Are you providing the solutions when you aren’t supposed to? Hard to tell on my phone screen.

1 Like

Ah, I found the issue. I did misread the error message (go figure).

@JeremyLT beat me to it - yes, you are defaulting to printing the solutions. You should default to not printing the solutions.

2 Likes

thanks a lot, been on this same issue for days… wow

2 Likes

That’s coding for you. That last 10% takes forever!

Good work getting the whole thing working!

2 Likes

thank so much, that was the problem…