Input:
def arithmetic_arranger(problems,kraliyet=False):
z = 0
k = ""
d = ""
m = ""
s = ""
arithmetic_problems = ""
if len(problems) > 5:
return "Error: Too many problems."
for index in problems:
a = len(index[:index.find(" ")])
b = len(index[index.find(" ")+3:])
z = max(a,b)
if z > 4:
return "Error: Numbers cannot be more than four digits."
if index[index.find(" ")+1] not in "+-":
return "Error: Operator must be '+' or '-'."
for i in index:
if i not in "1234567890+- ":
return "Error: Numbers must only contain digits."
if b > a :
k += (" ") * (b-a +2)
else:
k += (" ") * 2
k += index[:index.find(" ")]
k += (" " * 4)
d += index[index.find(" ")+1]
if a >= b:
d += ((" ") * (a-b))
d += index[index.find(" ")+2:]
d += " " * 4
m += "-" * (z+2)
m += 4 * " "
s += (2 * " ")
s += str(eval(index))
s += (4 * " ")
k = k[:-4]
d = d[:-4]
m = m[:-4]
s = s[:-4]
if kraliyet == False:
arithmetic_problems = k + "\n" + d + "\n" + m
else:
arithmetic_problems = k + "\n" + d + "\n" + m + "\n" + s
return arithmetic_problems
Output:
32 3801 45 123
+ 698 - 2 + 43 + 49
----- ------ ---- -----
...F..
======================================================================
FAIL: test_solutions (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/FinishedCrispMicrocode/test_module.py", line 66, in test_solutions
self.assertEqual(
AssertionError: ' 3[70 chars] ------ ---- -----\n -666 -3800 88 172' != ' 3[70 chars] ------ ---- -----\n -666 -3800 88 172'
32 1 45 123
- 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.004s
FAILED (failures=1)
What is the problem guys, can you help me please ?