Arithmetic_arranger decoding the exact error

Sorry for the format of this Post

I am having trouble analyzing what is the exact problem.
I cannot decode the assertion error to understand where is the mismatch.
How to read this?

here is the code

F..F..
================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-arithmetic-formatter/test_module.py", line 11, in test_arrangement
    self.assertEqual(
AssertionError: '    [23 chars]  123    \n+ 855    -    2    + 43    +  49   [35 chars]    ' != '    [23 chars]  123\n+ 855    -    2    + 43    +  49\n-----[23 chars]----'
-     3      3801      45      123    
?                                 ----
+     3      3801      45      123
- + 855    -    2    + 43    +  49    
?                                 ----
+ + 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/test_module.py", line 66, in test_solutions
    self.assertEqual(
AssertionError: '   3[23 chars]  123    \n- 698    - 3801    + 43    +  49   [73 chars]    ' != '   3[23 chars]  123\n- 698    - 3801    + 43    +  49\n-----[57 chars] 172'
-    32         1      45      123    
?                                 ----
+    32         1      45      123
- - 698    - 3801    + 43    +  49    
?                                 ----
+ - 698    - 3801    + 43    +  49
- -----    ------    ----    -----    
?                                 ----
+ -----    ------    ----    -----
-  -666     -3800      88      172    ?                                 ----
+  -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.010s

FAILED (failures=2)

this part shows you your lines starting with -, the expected lines starting with +, and the lines with ? point out the difference

in this case you have extra stuff at the end of the lines

Thank you… Now I see it…

Tell us what’s happening:
After correcting the last verification errors extra 4 spaces
The problem moved to

AssertionError: 'Error: Too many problems.' != '  11      3801      1      123         1\[79 chars]----'
- Error: Too many problems.
+   11      3801      1      123         1
+  4    - 2999    + 2    +  49    - 9380
----    ------    ---    -----    ------
 : Expected different output when calling "arithmetic_arranger()" with ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]

----------------------------------------------------------------------
Ran 6 tests in 0.001s

FAILED (failures=1)

Your code so far

if not len(problems) < 5 :
    arranged_problems = "Error: Too many problems." 
    return "Error: Too many problems." 
  else :  
    for index, problem in enumerate(problems):

it works but it fails verification no matter how I implement the if statment
Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.81.

Challenge: Arithmetic Formatter

Link to the challenge:
Repl.it - boilerplate-arithmetic-formatter

Love the comment about some Genius :slight_smile:

From the readme with the project : * If there are too many problems supplied to the function. The limit is five, anything more will return:
Error: Too many problems.

Currently, you have a maximum of 4 problems :wink:

Looking at the output, the 5th problem is causing the fail by not having added enough space in this problem or between the 4th and 5th. Maybe the Genius wanted all lines adjusted to the largest space needed for each problem?

-   11      3801      1      123     1
+   11      3801      1      123         1
?                                    ++++
- +  4    - 2999    + 2    +  49- 9380
+ +  4    - 2999    + 2    +  49    - 9380
?                               ++++
- ----    ------    ---    -----------?                                -----
+ ----    ------    ---    -----    ------?                      +++++++++

well that is the problem it
it should not be worried about the format just the message “Error: Too many problems.”
re init all the variables
verified that the if statement works manually starting
started python
from arithmetic_arranger import arithmetic_arranger
arithmetic_arranger( [“11 + 4”, “3801 - 2999”, “1 + 2”, “123 + 49”, “1 - 9380”])
it works fine “Error: Too many problems.” is the return.
why is the verification failing

Fixed the 5 problems.
back to line 27 causing the fail

   32      3801      45      123
+ 698    -    2    + 43    +  49
-----    ------    ----    -----
.....F
======================================================================
FAIL: test_too_many_problems (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-arithmetic-formatter/test_module.py", line 27, in test_too_many_problems
    self.assertEqual(
AssertionError: '   44      909      45      123      888 [106 chars]----' != 'Error: Too many problems.'
+ Error: Too many problems.-    44      909      45      123      888      653
- + 815    -   2    + 43    +  49    +  40    +  87
- -----    -----    ----    -----    -----    ----- : Expected calling "arithmetic_arranger()" with more than five problems to return "Error: Too many problems."

----------------------------------------------------------------------
Ran 6 tests in 0.005s

FAILED (failures=1)
 

You tackled the most difficult part of the errors.
The assignment wants to be able to calculate a maximum of 5 problems, not 6 or more…(…line 17…_)

your line 27 did not cause an error when I ran the code?

got it … I been fiddling with the
if statement that I forgot to place it back to
len(problems) > 5

   32      3801      45      123
+ 698    -    2    + 43    +  49
-----    ------    ----    -----
......
----------------------------------------------------------------------
Ran 6 tests in 0.001s

OK
 

I hate it when that happens…

nice work, congrats!

Thank you very much for your help.

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