# Arithmetic Formatter in Python

[’ 32\n+ 698\n_____\n 730’, ’ 3801\n- 2\n______\n 3799’, ’ 45\n+ 43\n____\n 88’, ’ 123\n+ 49\n_____\n 172’]

I am getting results like this, how can i fix that?

``````       def arithmetic_arranger(problems, BOOL = True):
if len(problems) > 5:
return "error1"
else:
arranged = []
for problem in problems:
x = problem.split()
num1 = x
num2 = x
oper = x
if oper != "+" and oper != "-":
return "error2+-"

if not num1.isdigit() or not num2.isdigit():
return "number contains digits"
else:

if len(num1) > 4 or len(num2) > 4:
return "too long"
else:
if oper == "+":
else:
maxim = max(len(num1), len(num2))
width = maxim + 2
first_line = str(num1.rjust(width))
second_line = oper + str(num2.rjust(width - 1))
third = "_" * width
if BOOL:
arranged.append(first_line + "\n" + second_line + "\n" + third + "\n" + forth)
else:
arranged.append(first_line + "\n" + second_line + "\n" + third)
return arranged``````

What error messages are you getting exactly? Looking at your code there could be more than one, some of which will contain messages about returning the wromg messages…