Arithmetic formatter: how to align output horizontally

Hi,
In arithmetic formatter I am able to print answers in a correct format I guess, but I wonder how can I align output horizontally as it shoud be according to requirements. I know that I need to use arranged problems, but I confused with how to use it.

this is my current progress
image

my code

def arithmetic_arranger(problems, bool):
    for i in range(len(problems)):
      space1 = " "
      space2 = " "
      dashes = "-"
      answer = ""
      spacesBeforeAnswer = ""
      digit1 = problems[i].split(" ")[0]
      digit2 = problems[i].split(" ")[2]
      sign = problems[i].split(" ")[1]
      if len(digit1) > len(digit2):
          space1 = " " * (len(digit1) - len(digit2)) + " "
          dashes = dashes * len(digit1) + "--"
          if sign == "+":
            answer = int(digit1) + int(digit2)
          elif sign == "-":
            answer = int(digit1) - int(digit2)
          spacesBeforeAnswer = (len(dashes) - len(str(answer))) * " "
      if len(digit1) < len(digit2):
        space2 = " " * (len(digit2) - len(digit1)) + " "
        dashes = dashes * len(digit2) + "--"
        if sign == "+":
          answer = int(digit1) + int(digit2)
        elif sign == "-":
          answer = int(digit1) - int(digit2)
        spacesBeforeAnswer = (len(dashes) - len(str(answer))) * " "
        #print(len(digit2), len(digit1))
      if len(digit1) == len(digit2):
        dashes = dashes * len(digit1) + "--"
        if sign == "+":
          answer = int(digit1) + int(digit2)
        elif sign == "-":
          answer = int(digit1) - int(digit2)
        spacesBeforeAnswer = (len(dashes) - len(str(answer))) * " "
      print(' ' + space2 + digit1 + '\n' + sign  + space1 + digit2 + '\n' + dashes + '\n' + spacesBeforeAnswer + str(answer) )

    return arranged_problems

Hello!

You need to process the entire lines, not on a per problem basis.

How would you write the results here (on the forum, I mean)? You would not be able to write a problem at a time, you would need to write 3 to 4 lines depending on if you wanted to display the answer or not.

You need to do the same for your results. Check the tests and what each of them expects to give you an idea.