# Arithmetic\_arranger - can't understand error codes

**URL:** <https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [June 7, 2022, 4:08pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621 "2022-06-07T16:08:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenushr](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kenushr](https://forum.freecodecamp.org/u/kenushr)\
**Post date:** [June 7, 2022, 4:08pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/1 "2022-06-07T16:08:24Z")

</div>

I am working on the Arithmetic Arranger problem and I don’t know what the errors I am getting actually mean or how to fix them. The core for loop works, but once I put into replit, I get weird errors that I can’t even understand.

```auto
import re

def arithmetic_arranger(problems, solve = False):
  
  if len(problems) > 5:
     return "Error: Too many problems."

  top = ""
  bottom = ""
  newDash = ""
  newSum = ""
  
  for problem in problems:
    
    if re.search("[*]", problem) or re.search("[/]", problem):
      return "Error: Operator must be '+' or '-'"
    if re.search("^/s[0-9].+-", problem):
      return "Error: Numbers must only contain digits"
    firstNumber = problem.split(' ')[0]
    operator = problem.split(' ')[1]
    secondNumber = problem.split(' ')[2]
    if len(firstNumber) >= 5 or len(secondNumber) >= 5:
      return "Error: Numbers cannot be more than four digits."
    
    sum =""
    if(operator == "+"):
        sum = str(int(firstNumber)+int(secondNumber))
    else:
        sum = str(int(firstNumber)-int(secondNumber))

    length = max(len(firstNumber), len(secondNumber)) +2
    topLine = str(firstNumber).rjust(length)
    bottomLine = operator + str(secondNumber).rjust(length-1)
    result = sum.rjust(length)
    dash = ""
    for y in range(length):
        dash += "-"

    if problem != problems[-1]:
      top += topLine + " "
      bottom += bottomLine + " "
      newDash += dash + " "
      newSum += result + " "
    else:
        top += topLine
        bottom += bottomLine
        newDash += dash
        newSum += result
  
  if solve:
    answer = (top + "\n" + bottom + "\n" + newDash + "\n" + newSum)
  else:
    answer = (top + "\n" + bottom + "\n" + newDash)
    
    return answer

```

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36`

**Challenge:** Arithmetic Formatter

**Link to the challenge:**  
[https://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter](https://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter)

---

<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 7, 2022, 4:24pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/2 "2022-06-07T16:24:29Z")

</div>

please share the tests output you get from the test suite

* * *

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![bardel44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bardel44/32/262143_2.png) [@bardel44](https://forum.freecodecamp.org/u/bardel44)\
**Post date:** [June 7, 2022, 4:41pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/3 "2022-06-07T16:41:58Z")

</div>

Hey just finishes the first python cert, a couple months ago. Most of the error codes are because the test output != your output. That is, your solution isn’t equal to what the test file wants to you get. Try to look like by line for the keyword “!=” or “does not equal”… see what you are suppose to be getting and how you can fix your code.

I still vividly remember, going line by line with the test code to make sure spaces, etc matched up, for each case.

If you are working offline, you can also download/copy the test solutions, then enter them into your code and compare them one by one. That is what I would recommend, as I did all the code offline first.

---

<div class="post-metadata">

**Author:** ![kenushr](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kenushr](https://forum.freecodecamp.org/u/kenushr)\
**Post date:** [June 7, 2022, 9:43pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/4 "2022-06-07T21:43:04Z")

</div>

Thanks for the advice! I actually figured it out but thank you!

---

<div class="post-metadata">

**Author:** ![kenushr](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kenushr](https://forum.freecodecamp.org/u/kenushr)\
**Post date:** [June 7, 2022, 9:43pm UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/5 "2022-06-07T21:43:58Z")

</div>

Thanks, I forgot to add a period to the end of an error message and had to tweak my reg ex formatting and it works now!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [December 7, 2022, 9:44am UTC](https://forum.freecodecamp.org/t/arithmetic-arranger-cant-understand-error-codes/515621/6 "2022-12-07T09:44:59Z")

</div>

Closed on December 7, 2022, 9:44am UTC

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