# Cant find problrm

Tell us what’s happening:
so i think getting error because of formatting of the answer

``````import re
def arithmetic_arranger(problems, *args):

if len(problems) > 5:
return "Error: Too many problems."

num1_arr =[]
num2_arr =[]
dashes_arr =[]
ans_arr = []

for equation in problems:

equation = equation.split(" ")
num1 = equation[0]
sign = equation[1]
num2 = equation[2]
regex = "\D"
reg_sign =  re.search("[+-]", sign)

if  reg_sign:
if re.search(regex, num1) or re.search(regex, num2):
return "Error: Numbers must only contain digits."

if len(num1) > 4 or len(num2) > 4:
return "Error: Numbers cannot be more than four digits."

biggest_num = max(len(num1), len(num2))
spaces = biggest_num + 2
dashes = "-"*(spaces)

num1_arr.append(f"{int(num1):>{spaces}}")
num2_arr.append(f"{sign}{int(num2):>{spaces-1}}")
dashes_arr.append(dashes)
else:
return "Error: Operator must be '+' or '-'."

arranged_problems = ["    ".join(num1_arr).rstrip(),"    ".join(num2_arr).rstrip(),"    ".join(dashes_arr).rstrip(),"    ".join(ans_arr).rstrip()]
arranged_problems2 = "\n".join(arranged_problems)
#print( arranged_problems2)
return arranged_problems2
``````

the output

``````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: '    [72 chars] ------    ----    -----\n   858       3799       88       172' != '    [72 chars] ------    ----    -----'
3      3801      45      123
+ 855    -    2    + 43    +  49
- -----    ------    ----    -----
?                                 -
11      3801      1      123         1+  4    - 2999    + 2    +  49    - 9380----    ------    ---    -----    ------
15       802      3      172     -9379
F.....===============================================================
=======
FAIL: test_arrangement (test_module.UnitTests)
---------------------------------------------------------------
-------
Traceback (most recent call last):
File "/home/runner/fcc-arithmetic-arranger/test_module.py", l
ine 10, in test_arrangement
self.assertEqual(actual, expected, 'Expected different outp
ut when calling "arithmetic_arranger()" with ["3 + 855", "3801
- 2", "45 + 43", "123 + 49"]')
AssertionError: '    [68 chars]-    ------    ----    -----\n
858      3799      88      172' != '    [68 chars]-    ------
----    -----'
3      3801      45      123
+ 855    -    2    + 43    +  49
- -----    ------    ----    -----
?                                 -
+ -----    ------    ----    ------   858      3799      88
172 : Expected different output when calling "arithmetic_arra
nger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]

---------------------------------------------------------------
-------
Ran 6 tests in 0.003s

FAILED (failures=1)

``````

User Agent is: `Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0`.

Challenge: Arithmetic Formatter

can you share your repl? it’s easier to debug from there

Thank you for replying here the Repl

you just need to format them nicely, not solve them

i tried but cant really pinpoint wheres the problem exactly is

remove the solutions
do not solve the operations

I see you have

``````  11      3801      1      123         1
+  4    - 2999    + 2    +  49    - 9380
----    ------    ---    -----    ------
15       802      3      172     -9379
``````

as one of the solutions
well, you solved them, you must not solve them

remove the fourth line

1 Like

Ok Got it thanks for helping