```
def arithmetic_arranger(problems, show=False):
#maximum number of problems allowed are 5
if len(problems) > 5:
print('Error: Too many problems.')
quit()
line1 = ""
line2 = ""
line3 = ""
line4 = ""
for p in problems:
problem = p.split()
fnumber = problem[0]
operator = problem[1]
snumber = problem[2]
#operator should only contain '+' or '-'
if operator != '+' and operator != '-':
print("Error: Operator must be '+' or '-'.")
quit()
#Number cannot be more than 4 digits
if len(fnumber) > 4 or len(snumber) > 4:
print('Error: Numbers cannot be more than four digits.')
quit()
#finding length of the operands
longest_number = max(len(fnumber),len(snumber))
operator_position = longest_number + 2
#operands should only be digits
try:
fnumber_int = int(fnumber)
snumber_int = int(snumber)
except:
print('Error: Numbers must only contain digits.')
quit()
#evaluating the answer
if operator == '+':
answer = fnumber_int + snumber_int
else:
answer = fnumber_int - snumber_int
#arranging problems vertically
line1 = line1 + fnumber.rjust(operator_position) + (4*' ')
line2 = line2 + operator +snumber.rjust(operator_position - 1) + (4*' ')
line3 = line3 + '_' * operator_position + (4*' ')
line4 = str(answer).rjust(operator_position) + (4*' ')
arranged_problems = f"{line1}\n{line2}\n{line3}\n{line4}"
return arranged_problems
```

Can you post the error output?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.