# [SOLVED] Arithmetic Formatter issue/glitch

Tell us what’s happening:
Hello,

I’m currently doing the arithmetic_arranger challenge and I keep getting this error, the code looks right but this error keeps happeneing, any help would be apperiated!:

``````E               3      3801      45      123
E           + 855    -    2    + 43    +  49
E         - -----    ------    ----    -----
E         + -----    ------    ----    -----
E         ?                                 +
E         +   858      3799      88      172
``````

``````def arithmetic_arranger(problems):
# Error handling.
if (len(problems) > 5):
return "Error: Too many problems."

for i in problems:
i = i.split(" ")
if (i[1] not in ["+", "-"]):
return "Error: Operator must be '+' or '-'."

for i in problems:
i = i.split(" ")
i.remove(i[1])
for item in i:
if (item.isnumeric()):
if len(item) > 4:
return "Error: Numbers cannot be more than four digits."

else:
return "Error: Numbers must only contain digits."

# Actual code here:

first_line = ""
second_line = ""
third_line = ""
fourth_line = ""

for i in problems:
save = i
i = i.split(" ")

int_version = [int(i[0]), int(i[2])]
# First number is longer
if (len(i[0]) > len(i[2])):
first_line += " "*2 + i[0]
second_line += i[1] + " "*(len(i[0]) - len(i[2]) + 1) + i[2]
third_line += "-"*(2 + len(i[0]))

if i[1] == "+":
fourth_line +=  " "*((len(i[0]) + 2) - len(str(int_version[0] + int_version[1]))) + f"{int_version[0] + int_version[1]}"

else:
fourth_line += " "*((len(i[0]) + 2) - len(str(int_version[0] - int_version[1]))) + f"{int_version[0] - int_version[1]}"

# Second number is longer
elif (len(i[0]) < len(i[2])):
first_line += " "*(len(i[2]) + 2 - len(i[0])) + i[0]
second_line += f"{i[1]}" + " " + i[2]
third_line += "-"*(2 + len(i[2]))

if i[1] == "+":
fourth_line +=  " "*((len(i[2]) + 2) - len(str(int_version[0] + int_version[1]))) + f"{int_version[0] + int_version[1]}"

else:
fourth_line += ""*((len(i[2]) + 2) - len(str(int_version[0] - int_version[1]))) + f"{int_version[0] - int_version[1]}"

# They're both the same
elif(len(i[0]) == len(i[2])):
first_line += " "*(len(i[2]) + 2 - len(i[0])) + i[0]
second_line += f"{i[1]}" + " " + i[2]
third_line += "-"*(2 + len(i[0]))

if i[1] == "+":
fourth_line +=  " "*((len(i[0]) + 2) - len(str(int_version[0] + int_version[1]))) + f"{int_version[0] + int_version[1]}"

else:
fourth_line += " "*((len(i[0]) + 2) - len(str(int_version[0] - int_version[1]))) + f"{int_version[0] - int_version[1]}"

# If not last item in list
if (save != problems[-1]):
first_line += " "*4
second_line += " "*4
third_line += " "*4
fourth_line += " "*4

arranged_problems = first_line + "\n" + second_line + "\n" + third_line + "\n" + fourth_line
print(arranged_problems)
return arranged_problems
``````

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