Scientific Computing with Python Projects - Arithmetic Formatter - Calculations not being printer next to each other

Tell us what’s happening:
Describe your issue in detail here.
Hello,

I am doing the arithmetic formatter challenge, so far I got all the calculation showing properly, I am still half way; however, for some reason when the calculations are printed, they are printed one below the other instead of one next to each other.

NOTE: ‘I am printing the result instead of returning because I am doing this in Visual Studio code first’
Your code so far

def arithmetic_arranger(problems):
    arranged_problems = ''
    
    
    
    if len(problems) > 5:
       return "Error: Too many problems"

    
    for num in problems:
        numbers = num.split()
        
        numa = numbers[0].isnumeric()
        numb = numbers[2].isnumeric()
        
        if numbers[1] not in '-+':
            return "Error: Operator must be '+' or '-'."
      
        if numa is not True or numb is not True:
            return "Error: Numbers must only contain digits"
        
        if len(numbers[0]) > 4 or len(numbers[1]) > 4:
            return "Error: Numbers cannot be more than four digits."
            
        else:
            
            value1 = numbers[0]
            value2 = numbers[2]
            operator = numbers[1]

            if operator == '+':
                value3 =int(numbers[0]) + int(numbers[2])
            if operator == '-':
                value3 =int(numbers[0]) - int(numbers[2])   
            
            
        lengtha = len(numbers[0])
        # lengthb = len(numbers[2])
        lengthb =max(len(numbers[0]), len(numbers[2]))

        spaceb = lengthb+2
        line=spaceb
        temp_problems=' '

 value3 = str(value3)

        top = value1.rjust(spaceb) + '  '
        bottom = operator + value2.rjust(spaceb-1) + ' '
        base = '-'*line + ' '
        result = value3.rjust(spaceb) + ' '

        temp_problems += top+'\n'+bottom+'\n'+base+'\n'+result+'\n

arranged_problems = temp_problems
 print(arranged_problems)

Your browser information:

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

Challenge: Scientific Computing with Python Projects - Arithmetic Formatter

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.