# Python - Problem with the Arithmetic Formatter

**URL:** <https://forum.freecodecamp.org/t/python-problem-with-the-arithmetic-formatter/409566>\
**Category:** General\
**Created:** [July 14, 2020, 6:40am UTC](https://forum.freecodecamp.org/t/python-problem-with-the-arithmetic-formatter/409566 "2020-07-14T06:40:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![K2Dz5p](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/k2dz5p/32/168659_2.png) [@K2Dz5p](https://forum.freecodecamp.org/u/K2Dz5p)\
**Post date:** [July 14, 2020, 6:40am UTC](https://forum.freecodecamp.org/t/python-problem-with-the-arithmetic-formatter/409566/1 "2020-07-14T06:40:16Z")

</div>

Hello,  
I am not getting the expected output. Line 10 and 39 of the test module.  
I did a comparison between the output and the expected and the boolean were True.  
Could you help please ?

```auto
import re
import numpy as np

def arithmetic_arranger(problems, var=None):
    if var == None or var:
        ret = ''
        ans = 0
        upper_num = []
        lower_num = []
        opperand = []
        answer = []
        dash = []
        upper_txt = ''
        lower_txt = ''
        dash_txt = ''
        answer_txt = ''
        if len(problems) > 5.1:
            return('Error: Too many problems.')
        else:        
            for i in problems:
                x = i.split(" ")
                try:
                    if len(x[0]) > 4:
                        raise ValueError
                    if len(x[2]) > 4:
                        raise ValueError
                except ValueError:
                    return("Error: Numbers cannot be more than four digits.")
                    break
                try:
                    x[0] = int(x[0])
                    x[2] = int(x[2])
                except ValueError:
                    return('Error: Numbers must only contain digits.')
                    break
                try:   
                    if str(x[1]) != '+' and str(x[1]) != '-':
                        raise Exception
                    if x[1] == '+': 
                        ans = int(x[0]) + int(x[2])
                    if x[1] == '-': 
                        ans = int(x[0]) - int(x[2])
                except Exception:
                    return("Error: Operator must be '+' or '-'.")
                    break
                a = str(x[0])
                upper_num = upper_num + [a]
                b = str(x[2])
                lower_num = lower_num + [b]
                c = str(x[1])
                opperand = opperand + [c]
                d = str(ans)
                answer = answer + [d]
        t = 0
        opperand = ["{}{}".format(i,' ') for i in opperand]
        while t < len(upper_num):
            max = np.maximum(len(upper_num[t]),len(lower_num[t])) + 2
            if not(t+1 == len(upper_num)):
                upper_txt = upper_txt + upper_num[t].rjust(max) + ' '
                lower_txt = lower_txt + opperand[t] + lower_num[t].rjust(max-2) + ' '
                dash_txt = dash_txt + ((max)*'-') + ' '
                answer_txt = answer_txt + answer[t].rjust(max) + ' '
            else:
                upper_txt = upper_txt + upper_num[t].rjust(max)
                lower_txt = lower_txt + opperand[t] + lower_num[t].rjust(max-2)
                dash_txt = dash_txt + ((max)*'-')
                answer_txt = answer_txt + answer[t].rjust(max)
            t += 1
        if len(answer) == len(problems):
                str.rstrip(upper_txt)
                str.rstrip(lower_txt)
                str.rstrip(dash_txt)
                if var :
                    print(upper_txt+'\n'+lower_txt+'\n'+dash_txt+'\n'+answer_txt)
                else:
                    print(upper_txt+'\n'+lower_txt+'\n'+dash_txt)

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [July 14, 2020, 7:36am UTC](https://forum.freecodecamp.org/t/python-problem-with-the-arithmetic-formatter/409566/2 "2020-07-14T07:36:09Z")

</div>

I don’t see your function returning anything when there are no errors

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:47pm UTC](https://forum.freecodecamp.org/t/python-problem-with-the-arithmetic-formatter/409566/3 "2021-06-01T18:47:09Z")

</div>

Closed on June 1, 2021, 6:47pm UTC


