Help with Arithmatic Formatter

Hello, can anyone help, when I run code all the conditions were ok, but in test I got 10/10 Fails which I don’t understand
Here is the code

def arithmetic_arranger (problems, second_arg = False):
        
     firstnum =[]; 
     secondnum =[];
     operator =[];
     rez =[]
     problem =[]
     
     for x in problems:
          problem.append(x.lstrip().rstrip().split(" "))
          

     if len(problems)>5:
         aranged_problems_error = "Error: Too many problems"
         return (aranged_problems_error)
    

     for x in problem:
            
          try: 
                     firstnum.append(int(x[0]))
                     secondnum.append(int(x[2]))
                     operator.append(x[1])
          except :
                     aranged_problems_error = "Error: Numbers must only contain digits. "
                     return (aranged_problems_error)

          if  ((x[1]) == "*" or (x[1]) == "/"): 
               aranged_problems_error = "Error: Operator must be '+' or '-'. "  
               return (aranged_problems_error) 
           
     for x in range(len(firstnum)):      
          if (len(str(firstnum[x]))>4 or len(str(secondnum[x]))>4):
               aranged_problems_error = "Error: Numbers cannot be more than four digits. " 
               return (aranged_problems_error)

           
            
                 
     first_row =""
     second_row =""
     lines =""
     third_row=""
     aranged_problems =""
     for x in range(len(operator)):
            b = len(str(max(firstnum[x], secondnum[x])))
            c= (str(firstnum[x]).rjust(b+2, " "), " "*4)
            first_row +="".join(c)
           
     
                
     for x in range(len(operator)):
             b = len(str(max(firstnum[x], secondnum[x])))
             c= (str(operator[x]).ljust(1," "), str(secondnum[x]).rjust(b+1, " ")," "*4)
             second_row +="".join(c)
     
     
     for x in range(len(operator)): 
             b = len(str(max(firstnum[x], secondnum[x])))
             c= (str("-"*(b+2)).rjust(b), " "*4)
             lines +="".join(c)
           
     aranged_problems = (first_row + "\n" + second_row + "\n" + lines)
     
   
         
     if second_arg == True:
           for x in range(len(operator)):
               if (operator[x]== "+"):
                   rez.append(firstnum[x] + secondnum[x])
               else:
                   rez.append(firstnum[x] - secondnum[x])
    
           

           for x in range(len(operator)):
                   b = len(str(max(firstnum[x], secondnum[x])))
                   c= (str(rez[x]).rjust(b+2, " ")," "*4)
                   third_row +="".join(c)
           
           aranged_problems = (first_row + "\n" + second_row + "\n" + lines + "\n" + third_row)
           return (aranged_problems)
     else:
        return (aranged_problems)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Please provide a link to your replit so we can see the error messages.
A guess after a quick glance are excess spaces at the ends of your lines.

Ok thank you very much and sorry didn’t know, I’m new

https://replit.com/@NerminDedic/boilerplate-arithmetic-formatter-12#arithmetic_arranger.py

-     3      3801      45      123
+     3      3801      45      123    
?                                 ++++

Excess spaces at the end.

- Error: Too many problems.
?                         -
+ Error: Too many problems

Missing punctuation.

- Error: Numbers must only contain digits.
+ Error: Numbers must only contain digits. 
?                                         +

Excess space at the end.

Thank you very much for quick solution, I’ve been trying for a few days and couldn’t figure it out :slight_smile:

Try reading the error messages now that I pointed out what they mean.
It’s quite hard at first understanding what all the stuff means - but it’s good practice not just for the projects but later on when programming it’s vital to construct and thus understand such test-cases and their error messages.