I have done my code for the Arithmetic Formatter exercise and failed to pass the test in replit. However, i tested the case in my own python IDLE local host and manage to pass all of those.

Is there anything that I’m doing wrong?

Below is the code for the exercise.

def arithmetic_arranger(problems, display = False):

line_one = list()

line_two = list()

line_three = list()

line_four = list()

```
if len(problems) > 5:
print('Error: Too many problems.')
return
for problem in problems:
lst = problem.split()
first_number = lst[0]
operator = lst[1]
second_number = lst[2]
try:
int(first_number)
int(second_number)
except:
print('Error: Numbers must only contain digits.')
return
if len(first_number) > 4 or len(second_number) > 4:
print('Error: Numbers cannot be more than four digits.')
return
if operator == '+' or operator == '-':
length = max(len(first_number), len(second_number)) + 2
line_one.append(first_number.rjust(length))
line_two.append(operator + second_number.rjust(length-1))
line_three.append('-'*length)
if operator == '+':
solution = int(first_number) + int(second_number)
else:
solution = int(first_number) - int(second_number)
line_four.append(str(solution).rjust(length))
else:
print('Error: Operator must be \'+\' or \'-\'.')
return
one = ' '.join(line_one)
two = ' '.join(line_two)
three = ' '.join(line_three)
four = ' '.join(line_four)
print(one)
print(two)
print(three)
if display == True:
print(four)
```