Arithmetic Formatter-stuck and frustrated

My code runs just fine in my compiler, but the test modules are giving me these errors:
I can’t figure it out.
Code is below.
I appreciate any feedback y’all may have

FAIL: test_arrangement (test_module.UnitTests)

Traceback (most recent call last):
File “/home/runner/boilerplate-arithmetic-formatter-2/test_module.py”, line 10, in test_arrangement
self.assertEqual(actual, expected, ‘Expected different output when calling “arithmetic_arranger()” with [“3 + 855”, “3801 - 2”, “45 + 43”, “123 + 49”]’)
AssertionError: (None, None, None) != ’ 3 3801 45 123\n+ 855 [56 chars]----’ : Expected different output when calling “arithmetic_arranger()” with [“3 + 855”, “3801 - 2”, “45 + 43”, “123 + 49”]

======================================================================
FAIL: test_solutions (test_module.UnitTests)

Traceback (most recent call last):
File “/home/runner/boilerplate-arithmetic-formatter-2/test_module.py”, line 39, in test_solutions
self.assertEqual(actual, expected, ‘Expected solutions to be correctly displayed in output when calling “arithmetic_arranger()” with arithemetic problems and a second argument of True.’)
AssertionError: (None, None, None, None) != ’ 32 1 45 123\n- 698 [90 chars] 172’ : Expected solutions to be correctly displayed in output when calling “arithmetic_arranger()” with arithemetic problems and a second argument of True.

def arithmetic_arranger(problems, answer=False):
        if len(problems) > 5:
            error = "Too many problems! 5 At most!"
            return error
        else:

            line1 = []
            line2 = []
            line3 = []
            line4 = []
            quad_space = "    "

            for p in problems:
                item = p.split()
                num_1 = item[0]
                num_2 = item[2]
                operand = item[1]
                sum = ""

                if len(num_1) > 4 or len(num_2) > 4:
                    error = "One or more numbers are too long. 4 Digits MAX"
                    return error
                    # check if all digits.
                for digit in num_1, num_2:
                    if not digit.isdigit():
                        error = "Only numbers!"
                        return error

                if operand not in ["+", "-"]:
                    error = "Invalid operand"
                    return error

                if operand == "+":
                        sum = int(num_1) + int(num_2)
                elif operand == "-":
                        sum = int(num_1) - int(num_2)

                list = [num_1, num_2]

                max_el_length = len(max(list)) 
                                                    #length of longest number in set
                                                    # max_el_length + 2 = number of dashes


                top_line = f"{num_1:>{max_el_length + 2}}"
                dashed_line = "-" * (max_el_length + 2)
                bottom_line_spaces = len(dashed_line) - len(num_2) - 2
                bottom_line = operand + " " + (" " * bottom_line_spaces) + num_2
                sum_line_spaces = (max_el_length + 2) - len(str(sum))
                sum_line = (" " * sum_line_spaces) + str(sum)
                line1.append(top_line + quad_space)
                line2.append(bottom_line + quad_space)
                line3.append(dashed_line + quad_space)
                line4.append(sum_line + quad_space)
            
            #removes extra quad_space from the end of each last item in line
            line1[-1] = (line1[-1])[:-5]
            line2[-1] = (line2[-1])[:-5]
            line3[-1] = (line3[-1])[:-5]
            line4[-1] = (line4[-1])[:-5]


            i = ""
            j = ""
            k = ""
            l = ""

            for item in line1:
                i += item

            for item in line2:
                j += item

            for item in line3:
                k += item

            for item in line4:
                l += item


            if answer == False:
                arranged_problems = print(i), print(j), print(k)
            else:
                arranged_problems = print(i), print(j), print(k), print(l)

            return arranged_problems

Welcome to the forums @scorpio_147.

Your problem is here:

where you are printing the results instead of returning them. That is why the tests are telling you

The three Nones are what you are returning, when you only need to return the strings. The calling module will print (or whatever) the strings you return.

Good luck.

Thanks for the welcome and quick reply @jeremy.a.gray !
I see now how the print statements were a problem, so I fixed that part to this:

if boolean == True:        
    arranged_problems = i + "\n" + j + "\n" + k + "\n" + l
else:
    arranged_problems = i + "\n" + j + "\n" + k

return arranged_problems

Now it’s completely messing up my output, jumbling it up, but while I run the same code in my own compiler, the output is as it should be.
Any ideas what could be the problem now?