The Arithmetic formatter Test fails but my answer has the same format

Tell us what’s happening:
Describe your issue in detail here.
When I print the arithmetic arranger in the console it shows the same format as the answers given in test_module.py . then when I run main(), I didn’t manage to pass any of the tests besides the error tests. Can anyone tell me what I’m doing wrong in my code? thanks!!!
The first photo shows the results when I use the print function but then I don’t get it cause the test says I failed :frowning:

Your code so far
def arithmetic_arranger(numberset, statprint=False ):
# arrangment
line_1 = ‘’
line_11=
line_2 = ‘’
line_22 =
dash = ‘’
dashh =
total = ‘’
totall =
# count if there are more than 5 problems
if len(numberset) > 5:
return ‘Error: Too many problems.’
for x in numberset:
n = x.split()
l1 = n[0]
l2= n[2]
operand = n[1]

    # counting if numbers given are more than 4 digits
    if len(l1) > 4 or len(l2) > 4:
        return 'Error: Numbers cannot be more than four digits.'
    
    # seeing if there are only digits
    if not l1.isnumeric() or not l2.isnumeric():
        return 'Error: Numbers must only contain digits.'

   
    #now addition and subtraction
    if operand == '+' or operand== '-':
        if operand== '+':
  	      sum = str(int(l1) + int(l2))
        else:
          sum = str(int(l1) - int(l2))
    else:
      return "Error: Operator must be '+' or '-'."
  
  	#making the fixed length and formattting
    length = max(len(l1), len(l2)) + 2
    top = str(l1).rjust(length)
    bot = str(l2).rjust(length - 1)
    sums = str(sum).rjust(length)
  
    #assigning the formation
    line_11.append(top + '    ')
    line_22.append(operand + bot + '    ')
    dashh.append((length * '-') + '    ')
    totall.append(sums + '    ')
  	
#strip out spaces to the right of the string
line_1 = ''.join(line_11)
line_2 = ''.join(line_22)
dash = ''.join(dashh)
total = ''.join(totall)
line_1.rstrip()
line_2.rstrip()
dash.rstrip()
total.rstrip()

if statprint == False :
    arranged_problems = line_1 + "\n" + line_2 + "\n" + dash
else: 
    arranged_problems = line_1 + "\n" + line_2 + "\n" + dash + "\n" + total
  
return arranged_problems

Your browser information:

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

Challenge: Arithmetic Formatter

Link to the challenge:

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