Arithmetic Formatter Help and Tweaks with Errors

I am still getting two errors but I seem to be returning the correct format. Would someone mind helping me correct them or point me in the right direction. ? Below are the errors. https://replit.com/@GearRatio/boilerplate-arithmetic-formatter-1#arithmetic_arranger.py

 python main.py
   32      3801      45      123
+ 698    -    2    + 43    +  49
_____    ______    ____    _____
F..F..
======================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-arithmetic-formatter-1/test_module.py", line 10, in test_arrangement
    self.assertEqual(actual, expected, 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]')
AssertionError: '    [34 chars]5    -    2    + 43    +  49\n_____    ______    ____    _____' != '    [34 chars]5    -    2    + 43    +  49\n-----    ------    ----    -----'
      3      3801      45      123
  + 855    -    2    + 43    +  49
- _____    ______    ____    _____+ -----    ------    ----    ----- : Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]

======================================================================
FAIL: test_solutions (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-arithmetic-formatter-1/test_module.py", line 39, in test_solutions
    self.assertEqual(actual, expected, 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with arithmetic problems and a second argument of `True`.')
AssertionError: '   3[59 chars] 49\n_____    ______    ____    _____\n -666  [21 chars] 172' != '   3[59 chars] 49\n-----    ------    ----    -----\n -666  [21 chars] 172'
     32         1      45      123
  - 698    - 3801    + 43    +  49
- _____    ______    ____    _____
+ -----    ------    ----    -----
   -666     -3800      88      172 : Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with arithmetic problems and a second argument of `True`.

----------------------------------------------------------------------
Ran 6 tests in 0.002s

FAILED (failures=2)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36.

Challenge: Arithmetic Formatter

Link to the challenge:

Take a look at the lines under the problems, they should be made of dashes instead of underscores.

I still have one failure when I set the second argument to True. It appears that the output is off by one problem and I don’t understand why.

 python main.py
   32      3801      45      123
+ 698    -    2    + 43    +  49
-----    ------    ----    -----
  730      3799      88      172
F.....
======================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-arithmetic-formatter-1/test_module.py", line 10, in test_arrangement
    self.assertEqual(actual, expected, 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]')
AssertionError: '    [68 chars]-    ------    ----    -----\n  858      3799      88      172' != '    [68 chars]-    ------    ----    -----'
      3      3801      45      123
  + 855    -    2    + 43    +  49
- -----    ------    ----    -----
?                                 -
+ -----    ------    ----    ------   858      3799      88      172 : Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]

----------------------------------------------------------------------
Ran 6 tests in 0.004s

FAILED (failures=1)
 

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