**Tell us what’s happening:**

I am failing 4 out of the 6 tests but I don’t know why my code is failing.

Also, why is my code displaying like this in the forum? I just copied and pasted but the post is displaying it in a weird format.

**Your code so far**

def arithmetic_arranger(problems, solve = False):

line1 = “”

line2 = “”

line3 = “”

line4 = “”

if len(problems) > 5:

return “Error: Too many problems.”

for i in problems:

first, operator, second = i.split()

```
if operator != '+' or operator != '-':
return "Error: Operator must be '+' or '-'."
if not first.isdigit() or not second.isdigit():
return "Error: Numbers must only contain digits."
if len(first) > 4 or len(second) > 4:
return "Error: Numbers cannot be more than four digits."
if operator == '+':
answer = int(first) + int(second)
else:
answer = int(first) - int(second)
total_length = max(len(first), len(second)) + 2
space1 = total_length - len(first)
space2 = total_length - len(second) - len(operator)
space4 = total_length - len(str(answer))
line1 += space1 * ' ' + first
line2 += operator + ' ' * space2 + second
line3 += "-" * total_length
line4 += space4 * ' ' + str(answer)
if i < len(problems) - 1:
line1 += " "
line2 += " "
line3 += " "
line4 += " "
```

arranged_problems = (line1 + ‘\n’ + line2 + ‘\n’ + line3)

if solve:

arranged_problems += ‘\n’ + line4

```
return arranged_problems
```

**Your browser information:**

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

.

**Challenge:** Arithmetic Formatter

**Link to the challenge:**