Assertion Error

Tell us what’s happening:
I am trying to complete the arithmetic formatted project and have completed the code without the error checks. When I run it, I am getting assertion errors in all test cases and I cant understand what it is from or why.

Your code so far

Your browser information:

User Agent is: Chrome/93.0.4577.63

Challenge: Arithmetic Formatter

Link to the challenge:

Try going through them one by one. For example, the first test:

arguments = [['3801 - 2', '123 + 49']], expected_output = '  3801      123\n-    2    +  49\n------    -----'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]'

>   ???
E   AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E   assert '  3801      ...--    -----\n' == '  3801      ...----    -----'
E     Skipping 36 identical leading characters in diff, use -v to show
E     - --    -----
E     + --    -----
E     ?            +

/home/runner/boilerplate-arithmetic-formatter-4/test_module.py:77: AssertionError

There’s error, that function didn’t return expected string

E   assert '  3801      ...--    -----\n' == '  3801      ...----    -----'
E     Skipping 36 identical leading characters in diff, use -v to show
E     - --    -----
E     + --    -----
E     ?            +

If you look closer at the output you will see there one additional character, in what function returned, but it shouldn’t be there.

I’ll go through it once again… the output is the second code block right? And I’m assuming its the one after ‘assert’ till the last + sign?

I think the first one is returned by the function, the latter is the expected by test.

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