I have no clue why this isnt working. it seems to work fine if I run the tests manually. but it fails on both arrangement and solutions. But if I manually print them they look exactly like they’re supposed to.

**Your code so far**

```
def arithmetic_arranger(problems, optional_answers = False):
first_numbers = []
operands = []
second_numbers = []
dashes = []
answers = []
arranged_problems = ""
#checking for too many problems
if len(problems) > 5:
return "Error: Too many problems."
for problem in problems:
length = 0
current_problem = problem.split()
#checking for errors
if current_problem[0].isdigit() == False or current_problem[2].isdigit() == False:
return "Error: Numbers must only contain digits."
if current_problem[1] not in ('-', '+'):
return "Error: Operator must be '+' or '-'."
if len(current_problem[0]) > 4 or len(current_problem[2]) > 4:
return "Error: Numbers cannot be more than four digits."
#checking for the longest number
if len(current_problem[0]) >= len(current_problem[2]):
first_numbers.append(current_problem[0].rjust(len(current_problem[0])+2))
second_numbers.append(current_problem[2].rjust(len(current_problem[0])+2).replace(" ", current_problem[1],1))
dashes.append("".rjust(len(current_problem[0])+2,"-"))
if optional_answers == True:
if current_problem[1] == "-":
answer = int(current_problem[0]) - int(current_problem[2])
answers.append(str(answer).rjust(len(current_problem[0])+2))
else:
answer = int(current_problem[0]) + int(current_problem[2])
answers.append(str(answer).rjust(len(current_problem[0])+2))
else:
first_numbers.append(current_problem[0].rjust(len(current_problem[2])+2))
second_numbers.append(current_problem[2].rjust(len(current_problem[2])+2).replace(" ", current_problem[1],1))
dashes.append("".rjust(len(current_problem[2])+2,"-"))
if optional_answers == True:
if current_problem[1] == "-":
answer = int(current_problem[0]) - int(current_problem[2])
answers.append(str(answer).rjust(len(current_problem[2])+2))
else:
answer = int(current_problem[0]) + int(current_problem[2])
answers.append(str(answer).rjust(len(current_problem[2])+2))
for number in first_numbers:
arranged_problems += number + " "
arranged_problems.strip()
arranged_problems += "\n"
for number in second_numbers:
arranged_problems += number + " "
arranged_problems.strip()
arranged_problems += "\n"
for line in dashes:
arranged_problems += line + " "
arranged_problems.strip()
arranged_problems += "\n"
for line in answers:
arranged_problems += line + " "
arranged_problems.strip()
arranged_problems += "\n"
return arranged_problems
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0`

.

**Challenge:** Arithmetic Formatter

**Link to the challenge:**