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
Your code so far
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[0])
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)
Your browser information:
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
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.
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.