# Randomly prints 3 dots

Tell us what’s happening:
code passes the tests when the actual tests are copied into main.py, but fails in the test module as a random “…” is appended onto the start of line 1 for the final test

``````def arithmetic_arranger(x, y=False):
arranged_problems = ""
okchars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", " "]
arithlist = []
for i in x:
p = i.find("+")
m = i.find("-")
if p == -1 and m == -1:
return("Error: Operator must be '+' or '-'.")
for r in i:
if (r in okchars):
pass
else:
return("Error: Numbers must only contain digits.")
if len(x) > 5:
return("Error: Too many problems.")
else:
line1 = str("")
line2 = str("")
line3 = str("")
for i in x:
iinit = i
space = i.find(" ")
num1 = str(i[0:space])
i = i[(space+1):]
op = str(i)
num2 = str(i[2:])
if len(num1) > 4 or len(num2) > 4:
return("Error: Numbers cannot be more than four digits.")
hosi = max(len(num1), len(num2))
line1 = str(line1 + spacemaker(hosi + 2 - len(num1), " ") + num1)
line2 = str(line2 + op + spacemaker(hosi + 1 - len(num2), " ") + num2)
line3 = str(line3 + spacemaker(hosi + 2, "-"))
if iinit != x[-1]:
line1 = str(line1 + "    ")
line2 = str(line2 + "    ")
line3 = str(line3 + "    ")
else:
pass
arranged_problems = str(line1 + "\n" + line2 + "\n" + line3)
arranged_problems = arranged_problems.replace(".", "")
if y == True:
pass
print(arranged_problems)
else:
pass
return (arranged_problems)
def spacemaker(k, c):
l = 0
buf = str("")
while l < k:
buf = str(buf + str(c))
l += 1
return str(buf)
``````

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

Challenge: Arithmetic Formatter

test module output for the final test_solutions test is as follows:

``````...   32         1      45      123
- 698    - 3801    + 43    +  49
-----    ------    ----    -----
``````

but these 3 lines dont appear when the code is just run in main.py:

``````   32         1      45      123
- 698    - 3801    + 43    +  49
-----    ------    ----    -----
``````

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 (’).

would you please share your repl so that people can run your code and see the output?

I’m unsure what you mean by repl?

were you working on this on replit.com?

Yes - do you want me to send a link?

yes, so it’s possible to run your code and see the output

I’m removing the join link, that allows anyone to modify your code

You have one test still failing

``````FAIL: test_solutions (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/Wugi4wkX4iN/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[68 chars]-    ------    ----    -----' != '   3[68 chars]-    ------    ----    -----\n -666     -3800      88      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`.
``````

you are missing the solutions in this case

Ha, yes. Thank you, fully reading the question does help. How stupid.
Are you able to tell me where the three dots come from?

probably one of your print statements is printing on the same line of those dots. If you run without any code, those appear anyway

I think you’re looking at the wrong thing. You need to be looking at the Assertion Error and comparing your output to the expected output:

``````'   3[68 chars]-    ------    ----    -----' !=
'   3[68 chars]-    ------    ----    -----\n -666     -3800      88      172'
``````
1 Like

Is this your first project on FCC?
The three dots are the result of the test-module A dot represents a passed test, whereas something like a “f” represent a failed test. They are without a newline, so an actual print-statement would start right behind them - ofcourse if you run the code without the tests somewhere else, they won’t appear.

cool thank you, and I’ve sorted the error as well. Thank you everyone for your help

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