Hello.

I’m having trouble understading the feedback of the unit tests. When I run my program, I don’t fully understand what it’s trying to tell me.

Here is the output of the unit tests

```
F..F..
======================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/fcc-arithmetic-arranger/test_module.py", line 10, in test_arrangement
self.assertEqual(actual, expected, 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]')
AssertionError: ' [23 chars] 123 \n+ 855 - 2 + 43 + 49 [37 chars] \n' != ' [23 chars] 123\n+ 855 - 2 + 43 + 49\n-----[23 chars]----'
- 3 3801 45 123
? ----
+ 3 3801 45 123
- + 855 - 2 + 43 + 49
? ----
+ + 855 - 2 + 43 + 49
- ----- ------ ---- -----
? -----
+ ----- ------ ---- ----- : Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]
======================================================================
FAIL: test_solutions (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/fcc-arithmetic-arranger/test_module.py", line 39, in test_solutions
self.assertEqual(actual, expected, 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with arithemetic problems and a second argument of `True`.')
AssertionError: ' 3[23 chars] 123 \n- 698 - 3801 + 43 + 49 [75 chars] \n' != ' 3[23 chars] 123\n- 698 - 3801 + 43 + 49\n-----[57 chars] 172'
- 32 1 45 123
? ----
+ 32 1 45 123
- - 698 - 3801 + 43 + 49
? ----
+ - 698 - 3801 + 43 + 49
- ----- ------ ---- -----
? ----
+ ----- ------ ---- -----
- -666 -3800 88 172
? -----
+ -666 -3800 88 172 : Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with arithemetic problems and a second argument of `True`.
----------------------------------------------------------------------
Ran 6 tests in 0.006s
FAILED (failures=2)
```

This is my implementation of the exercise

```
NUM_INDENT = 4
def arithmetic_arranger(problems, show_solution = False):
""" Given a list of simple algebraic prompts, the function will return a string with the operations formatted """
e_ManyProb, e_Op, e_NAN, e_Large = False, False, False, False
arranged_problems = str()
slicedprob = list()
if len(problems) > 5:
e_ManyProb = True
else:
indent = " " * NUM_INDENT
for problem in problems:
curr = problem.strip().split()
if curr[1] != "+" and curr[1] != "-":
e_Op = True
break
try:
int(curr[0])
int(curr[2])
except:
e_NAN = True
break
if len(curr[0]) > 4 or len(curr[2]) > 4:
e_Large = True
break
# This is usefull to calculate the spacing
curr.append( max(len(curr[0]), len(curr[2])) )
slicedprob.append(curr)
if e_ManyProb:
arranged_problems = "Error: Too many problems."
elif e_Op:
arranged_problems = "Error: Operator must be '+' or '-'."
elif e_NAN:
arranged_problems = "Error: Numbers must only contain digits."
elif e_Large:
arranged_problems = "Error: Numbers cannot be more than four digits."
else:
#TODO: Fix formatting with .rjust() method
for op in slicedprob:
extraWhiteSpace = (op[3] - len(op[0])) * " "
arranged_problems += " " + extraWhiteSpace + op[0] + indent
arranged_problems += "\n"
for op in slicedprob:
extraWhiteSpace = (op[3] - len(op[2])) * " "
arranged_problems += op[1] + " " + extraWhiteSpace + op[2] + indent
arranged_problems += "\n"
for op in slicedprob:
arranged_problems += "-" * (op[3] + 2) + indent
arranged_problems += "\n"
if show_solution:
for op in slicedprob:
sol = 0
if op[1] == "+":
sol = int(op[0]) + int(op[2])
else:
sol = int(op[0]) - int(op[2])
arranged_problems += str(sol).rjust(op[3] + 2) + indent
arranged_problems += "\n"
return arranged_problems
```

Pointers are also appreciated, regarding best practices.

Thank you for your time!

EDIT1: In my case the problem was

- I was printing an extra 4 spaces at the end of every line
- I was printing a final “\n” when it wasn’t needed