Arithmetic arranger

hello everyone,

I’ve had a problem must be missing something with an else statement but got no clue after debugging and error searching. so i can either pass the first half of the test and 20% wrong or fail the first 4 tests and get 40% wrong , weither i choose to put ==True or not. not sure but maybe something with my if and else statement that could mess it up to? my result is set to False in the top


https://replit.com/@Strayhat/boilerplate-arithmetic-formatter#arithmetic_arranger.py/

Those pictures are really hard to read. It is better to post the actual error messages.

You should not need result == True, just result.

Edit: AHHHHH - you are overwriting result inside of your loop. Big No-No!

1 Like

ah sorry my bad ,

with the result==True i get this error

E       AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.
E       assert '    3      988\n+ 855    +  40\n-----    -----' == '    3      988\n+ 855    +  40\n-----    -----\n  858     1028'
E               3      988
E           + 855    +  40
E         - -----    -----
E         ?               -
E         + -----    -----
E         -   858     1028

when i remove ==True and just use result this happens.

E       AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E       assert '  3801      123\n-    2    +  49\n------    -----\n  3799      172' == '  3801      123\n-    2    +  49\n------    -----'
E             3801      123
E           -    2    +  49
E         - ------    -----
E         + ------    -----
E         ?                +
E         +   3799      172

As @JeremyLT stated above, in your for loop you are reassigning a value to result.

        if op == "+":
            result = int(alpha) + int(bravo)
        else:
            result = int(alpha) - int(bravo)
1 Like

============================ 10 passed in 0.09s

both of you thank you so much for the help , @JeremyLT @RandellDawson

1 Like