I’ve worked out arithmetic arranger() to satisfy all the criteria visually, but 6 of the tests are failing because the expected output does not match the string for the two-problem, four problem and five problem tests. The Full output is truncated, so I can’t see the whole error message. I’m supposed to use -vv to see it, but that command does not work in the console. Any ideas?

My code looks perfect in the output window, and I can’t get the actual string to print to compare it with the expected string. I just get the formatted view in the console window.

Any thoughts on how to proceed?

**Your code so far**

```
def arithmetic_arranger(problems, solve = False):
if len(problems) > 5:
return("Error: Too many problems.")
arranged_problems = "wtf"
if(not None):
#these hold value of current problem
firstNum = ''
operator = ''
secondNum = ''
#these hold the current state of each row
first_row = ''
second_row = ''
third_row = ''
fourth_row = ''
#this holds the final string to be returned
format_string = ''
for problem in problems:
top_space = ''
bottom_space = ''
solution_space = ''
solution = ''
#print(re.search("[^\s0-9.+-]", problem))
if(re.search("[^\s0-9.+-]", problem)):
if ('/' in problem or '*' in problem):
return("Error: Operator must be '+' or '-'.")
return("Error: Numbers must only contain digits.")
#print(problem)
#split problem into three parts
column = problem.split(' ')
firstNum = column[0]
secondNum = column[2]
#determine how many spaces are needed for top row alignment
column_width = max(len(firstNum), len(secondNum)) + 2
lines = ''
top_spaces = column_width - len(firstNum)
#print(top_spaces)
#add required spaces to top row
while top_spaces > 0:
top_space = top_space + ' '
top_spaces = top_spaces - 1
#select operator and add 1 space
operator = column[1] + ' '
if operator == '+ ':
solution = int(firstNum) + int(secondNum)
else:
solution = int(firstNum) - int(secondNum)
string_solution = str(solution)
#determine number of spaces needed for second row alignment
bottom_spaces = column_width - 2 - len(secondNum)
#add those spaces to second row
while bottom_spaces > 0:
bottom_space = bottom_space + ' '
bottom_spaces = bottom_spaces - 1
#check number length
#determine spaces needed to format fourth row
solution_spaces = column_width - len(string_solution)
#print(column_width)
#add spaces to current problem
while solution_spaces > 0:
solution_space = solution_space + ' '
solution_spaces = solution_spaces - 1
#add lines on third row
while column_width > 0:
lines = lines + '_'
column_width = column_width - 1
if (len(firstNum) > 4 or len(secondNum) > 4):
return("Error: Numbers cannot be more than four digits.")
first_row = first_row + top_space + firstNum + ' '
second_row = second_row + operator + bottom_space + secondNum + ' '
third_row = third_row + lines + ' '
if solve:
fourth_row = fourth_row + solution_space + string_solution + '
format_string = first_row + '\n' + second_row + '\n' + third_row + '\n' + fourth_row
print(format_string)
arranged_problems = format_string
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/96.0.4664.93 Safari/537.36`

**Challenge:** Arithmetic Formatter

**Link to the challenge:**