Failing 2/6 Unit Tests

Tell us what’s happening:
Hello, I am failing the test_arrangement and test_solutions tests. It seems to output fine in the arithmetic_arranger file. Also, this is my first experience with unit testing…

Your code so far

import re # regular expressions
def arithmetic_arranger(problems, with_results = False):
    if len(problems) > 5:
        return "Error: Too many problems."

    arranged_problems = [[], [], [], []]

    for problem in problems:
        if "*" in problem or "/" in problem:
            return "Error: Operator must be '+' or '-'."

        if"[a-zA-Z]", problem) != None or "." in problem:
            return "Error: Numbers must only contain digits."
        if "+" in problem or "-" in problem:
            number_1 = re.split("\+|\-", problem)[0].strip()
            number_2 = re.split("\+|\-", problem)[1].strip()
            if len(number_1) > 4 or len(number_2) > 4:
                return "Error: Numbers cannot be more than four digits."

        # No user error...
        # Line 1...
        # Line 2...
        # Line 3
        if (max(len(number_1), len(number_2))) == 1:
        elif (max(len(number_1), len(number_2))) == 2:
        elif (max(len(number_1), len(number_2))) == 3:
        elif (max(len(number_1), len(number_2))) == 4:
        # Line 4
        if with_results == True:
            if "+" in problem:
                arranged_problems[3].append(str(int(number_1) + int(number_2)))
            elif "-" in problem:
                arranged_problems[3].append(str(int(number_1) - int(number_2)))

    line_one = arranged_problems[0]
    line_two = arranged_problems[1]
    line_three = arranged_problems[2]
    line_four = arranged_problems[3]

    problem_width = []
    for element in line_three:

    # Output formatting with \n character...
    separator = "    "

    for i in range(len(problems)):
        if line_one[i] != line_one[-1]:
            print(line_one[i].rjust(problem_width[i]), end = separator)
            print(line_one[i].rjust(problem_width[i]), end = "\n")

    for i in range(len(problems)):
        if "+" in problems[i]:
            if line_two[i] != line_two[-1]:
                print("+" + line_two[i].rjust(problem_width[i] - 1), end = separator)
                print("+" + line_two[i].rjust(problem_width[i] - 1), end = "\n")
        elif "-" in problems[i]:
            if line_two[i] != line_two[-1]:
                print("-" + line_two[i].rjust(problem_width[i] - 1), end = separator)
                print("-" + line_two[i].rjust(problem_width[i] - 1), end = "\n")
    if with_results == True:
        print(separator.join(line_three), end = "\n")

    if with_results == True:
        for i in range(len(problems)):
            if line_four[i] != line_four[-1]:
                print(line_four[i].rjust(problem_width[i]), end = separator)
                print(line_four[i].rjust(problem_width[i]), end = "\n")

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36.

Challenge: Arithmetic Formatter

Link to the challenge:

could you please share the link to your repl or give the error your are getting?

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 (’).

Hi, thank you so much for doing that. I don’t have it on but I have it on GitHub:

Error image 1:

Thanks again for your help!!!

Error Image 2: