# Scientific Computing with Python Projects - Arithmetic Formatter

Tell us what’s happening:
Describe your issue in detail here.

``````def arithmetic_arranger(problems, solve = False):
first= ""
second =""
lines = ""
sumx = ""
string= ""
if (len(problems) > 5):
return print("Error: Too many problems.")
for problem in problems:
operator = problem.split()[1]
op1 = problem.split()[0]
op2 = problem.split()[2]

if len(op1) > 4 or len(op2) > 4:
return print("Error: Numbers cannot be more than four digits.")
try:
op1 = int(op1)
op2 = int(op2)
except:
return print("Error: Numbers must only contain digits.")
if operator == "+":
sum = str(op1 + op2)
elif operator == "-":
sum = str(op1 - op2)
else:
return print("Error: Operator must be '+' or '-'")

length=max(len(str(op1)),len(str(op2)))+2
top= str(op1).rjust(length)
bottom = operator+str(op2).rjust(length-1)
line = ""
res = sum.rjust(length)
for l in range(length):
line += "-"
if problem != problems[-1]:
first +=  top + '    '
second += bottom + '    '
lines += line + '    '
sumx += res + '    '
else:
first += top
second += bottom
lines += line
sumx += res

if solve:
string = first +  "\n" + second + "\n" + lines + "\n" + sumx
else:
string = first +  "\n" + second + "\n" + lines
return print (string)
``````

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

Challenge: Scientific Computing with Python Projects - Arithmetic Formatter