# Arithmetic formatter i dont understand these error messages

I dont seem to pass any tests at all and i feel a bit stuck and lost as to what is wrong. Im a bit at my wits end here tbh.

Here is my code:

``````    i = 0
output = ""
while i < num:
output += " "
i += 1

return output

def arithmetic_arranger(problems, solve= False):

space = 4

#too many errors code
if len(problems) > 5:
return "Error: Too many problems."

#invalid operator code
forbidden = False
for item in problems:
split_item = (item.split(" "))

if split_item[1] != "+" and split_item[1] != "-":
forbidden = True

if forbidden == True:
return "Error: Operator must be '+' or '-'."

#invalid operand type code
forbidden_num = False
for item in problems:
split_item1 = item.split(" ")
if isinstance(split_item1[0],int) and isinstance(split_item1[2],int):
forbidden_num = True

if forbidden_num == True:
return "Error: Numbers must only contain digits."

#invalid number length code
forbidden_length = False
for item in problems:
split_item2 = item.split(" ")
if len(split_item2[0]) > 4 or len(split_item2[2]) > 4:
forbidden_length = True

if forbidden_length == True:
return "Error: Numbers cannot be more than four digits."

#biggest number length code
biggest_len = []

for item in problems:
word = item.split(" ")
if int(word[0]) > int(word[2]):
biggest_len.append(len(word[0]))

else:
biggest_len.append(len(word[2]))

#code for printing lines

lineoutput = ""

i = 0
for item in problems:
word = item.split(" ")
lineoutput += spaces(space)
lineoutput += "    "
word[0] = word[0].rjust(biggest_len[i])
lineoutput += word[0]
i += 1

#print(lineoutput)

lineoutput1 = ""

i = 0
for item in problems:
word = item.split(" ")
lineoutput1 += spaces(space)
word[2] = word[2].rjust(biggest_len[i])
lineoutput1 += "  " + word[1] + " " + word[2]
i += 1

#print(lineoutput1)

lineoutput2 = ""

i = 0
ii = 0
for item in problems:
word = item.split(" ")
lineoutput2 += spaces(space)
lineoutput2 += "  "

while ii < (biggest_len[i] + 2):
lineoutput2 += "-"
ii += 1

i += 1
ii = 0

lineoutput3 = ""

if solve is False:
arranged_problems = lineoutput + "\n" + lineoutput1 + "\n" + lineoutput2
else:

for item in problems:
word = item.split(" ")
if word[1] == "+":
else:
iii = 0

lineoutput3 += spaces(space)
lineoutput3 += str(item1).rjust(biggest_len[iii] + 4)
iii += 1

arranged_problems = lineoutput + "\n" + lineoutput1 + "\n" + lineoutput2 + "\n" + lineoutput3

return arranged_problems
``````

and i get loads of failures i just dont know where to start

`````` python main.py
32        3801        45        123
+ 698      -    2      + 43      +  49
-----      ------      ----      -----
F.EF..
======================================================================
ERROR: test_only_digits (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-arithmetic-formatter-1/test_module.py", line 32, in test_only_digits
actual = arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"])
File "/home/runner/boilerplate-arithmetic-formatter-1/arithmetic_arranger.py", line 55, in arithmetic_arranger
if int(word[0]) > int(word[2]):
ValueError: invalid literal for int() with base 10: '3g5'

======================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-arithmetic-formatter-1/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: '          3        3801        45        123\[87 chars]----' != '    3      3801      45      123\n+ 855    - [51 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/boilerplate-arithmetic-formatter-1/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: '         32           1        45        123[134 chars] 172' != '   32         1      45      123\n- 698    -[86 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.005s

FAILED (failures=2, errors=1)

``````

You have three tests passing, that’s indicated with the dots in `F.EF..`
Try to go through errors and fix them one by one, that will be easier than trying to fix everything at once.

In one case you have given exception and (`ValueError`) and line which is causing it. I’d start from that one.