Stuck, my code works perfectly in atom, but not in repl

Tell us what’s happening:
So i have fixed my code multiple times, and tested it in atom, however in repl it keeps giving me multiple errors.

This is my first python project, forgive me if the problem is silly.

Your code so far

        def arithmetic_arranger(problems,optional = None):

    line1 = ""
    line2 = ""
    line3 = ""
    line4 = ""

    if len(problems) >5:
        print('Error: Too many problems.')
        quit()

    num1 =[]
    op = []
    num2 = []

    for each in range(len(problems)):
        number= problems[each]
        num = number.split()
        num1.append(num[0])
        op.append(num[1])
        num2.append(num[2])

    for x in num1:
        if x.isdigit() != True:
            print("Error: Numbers must only contain digits")
            quit()
        if len(x) > 4:
            print("Error: Numbers cannot be more than four digits.")
            quit()

    for y in num2:
        if y.isdigit() != True:
            print("Error: Numbers must only contain digits")
            quit()
        if len(y) > 4:
            print("Error: Numbers cannot be more than four digits.")
            quit()

    for o in op:
        if o == '*' or o == '/':
            print("Error: Operator must be '+' or '-'.")
            quit()

    results = []
    for z in range(len(num1)):
        result = None
        try:
            if op[z] == '+':
                result = int(num1[z]) + int(num2[z])
                results.append(result)
            elif op[z] == '-':
                result = int(num1[z]) - int(num2[z])
                results.append(result)
        except:
            break

        length = max(len(num1[z]),len(num2[z]))

        line1 += num1[z].rjust(length+2)+"    "
        line2 += op[z]+" "+num2[z].rjust(length)+"    "
        line3 += "-"*(length+2)+"    "
        line4 += str(results[z]).rjust(length+2)+"    "

        if optional == True:
            arranged_problems = line1+"\n"+line2+"\n"+line3+"\n"+line4
        else:
            arranged_problems = line1+"\n"+line2+"\n"+line3

    return arranged_problems

my repl comments

   32      3801      45      123    
+ 698    -    2    + 43    +  49    
-----    ------    ----    -----    
FError: Operator must be '+' or '-'.
EError: Numbers must only contain digits
EFError: Numbers cannot be more than four digits.
EError: Too many problems.
E
======================================================================
ERROR: test_incorrect_operator (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/InconsequentialStripedRatios/test_module.py", line 22, in test_incorrect_operator
    actual = arithmetic_arranger(["3 / 855", "3801 - 2", "45 + 43", "123 + 49"])
  File "/home/runner/InconsequentialStripedRatios/arithmetic_arranger.py", line 42, in arithmetic_arranger
    quit()
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None

======================================================================
ERROR: test_only_digits (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/InconsequentialStripedRatios/test_module.py", line 32, in test_only_digits
    actual = arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"])
  File "/home/runner/InconsequentialStripedRatios/arithmetic_arranger.py", line 34, in arithmetic_arranger
    quit()
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None

======================================================================
ERROR: test_too_many_digits (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/InconsequentialStripedRatios/test_module.py", line 27, in test_too_many_digits
    actual = arithmetic_arranger(["24 + 85215", "3801 - 2", "45 + 43", "123 + 49"])
  File "/home/runner/InconsequentialStripedRatios/arithmetic_arranger.py", line 37, in arithmetic_arranger
    quit()
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None

======================================================================
ERROR: test_too_many_problems (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/InconsequentialStripedRatios/test_module.py", line 17, in test_too_many_problems
    actual = arithmetic_arranger(["44 + 815", "909 - 2", "45 + 43", "123 + 49", "888 + 40", "653 + 87"])
  File "/home/runner/InconsequentialStripedRatios/arithmetic_arranger.py", line 10, in arithmetic_arranger
    quit()
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None

======================================================================
FAIL: test_arrangement (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/InconsequentialStripedRatios/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: '    [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/InconsequentialStripedRatios/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 arithemetic problems and a second argument of `True`.')
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 arithemetic problems and a second argument of `True`.

----------------------------------------------------------------------
Ran 6 tests in 0.096s

FAILED (failures=2, errors=4)

Your browser information:

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

Challenge: Arithmetic Formatter

Link to the challenge:

please share your repl


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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).