Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project

Hi there

I’ve copy pasted the tests and what they should return. From my point of view everything, including the Test and answers are coming out as they should. I am passing on #5-8 with the errors, but it’s telling me that the answers aren’t coming up as they should, even though from my point of view they are.

Any help would be appreciated.

def arithmetic_arranger(problems, show_answers=False):
    probs_thirds = [thirds.split() for thirds in problems]

    if len(problems) > 5:
        return('Error: Too many problems.')

    for prob in probs_thirds:
        if (len(prob[0]) > 4) or (len(prob[2])) > 4:
            return('Error: Numbers cannot be more than four digits.')
        if not prob[0].isdigit() or not prob[2].isdigit():
            return('Error: Numbers must only contain digits.')
        if prob[1] in ['/','*']:
            return("Error: Operator must be '+' or '-'.")


    answers = [eval(sols) for sols in problems]

    for inner_probs, ans in zip(probs_thirds, answers):
            inner_probs.append(str(ans))

    aligned_problems = [[
            prob[0].rjust(max(len(prob[0]), len(prob[2])) + 2), 
            f"{prob[1]} {prob[2].rjust(max(len(prob[0]), len(prob[2])))}", 
            prob[3].rjust(max(len(prob[0]), len(prob[2])) + 2) 
        ]for prob in probs_thirds]

    aligned_updated = [[
            prob[0].rjust(max(len(prob[0]),len(prob[1]), len(prob[2]))), 
            prob[1].rjust(max(len(prob[0]),len(prob[1]), len(prob[2]))),
            prob[2].rjust(max(len(prob[0]),len(prob[1]), len(prob[2]))), 
                ]for prob in aligned_problems]

    for inner_list in aligned_updated:
            length = max(len(string) for string in inner_list)
            dashes = '-' * length
            inner_list.append(dashes)

    aligned_spaced = [[nums + " " * 4 for nums in lists] for lists in aligned_updated]

    first_row = [inner[0] for inner in aligned_spaced]
    second_row = [inner[1] for inner in aligned_spaced]
    third_row = [inner[2] for inner in aligned_spaced] #this row is the answers
    fourth_row = [inner[3] for inner in aligned_spaced] #this row is the dashes

    if show_answers == True:
        arranged_output = (
        ''.join(first_row) + '\n' + 
        ''.join(second_row) + '\n' +
        ''.join(fourth_row) + '\n' +
        ''.join(third_row))
        return arranged_output

    else:
        arranged_output = (
        ''.join(first_row) + '\n' + 
        ''.join(second_row) + '\n' +
        ''.join(fourth_row))

        return arranged_output

print(f'\n{arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49", "988 + 40"], True)}')

Doesn’t matter. I used repr() and found out what was wrong.