 # Unable to pass even though my output seems correct. May I know what's wrong in my code?

Tell us what’s happening:
Describe your issue in detail here.
It’s telling me that my output is wrong but I am not sure where did I make a mistake
because when I am comparing the output, it looks the same as mine. May I know what is wrong in my code here?

``````def arithmetic_arranger(problems,chk = False):
sign = ""
val = problems
ln = len(val)
if ln > 5:
return "Error: Too many problems."
fline = ""
sline = ""
dline = ""
ansline = ""
for i in val:
first = i.split()
num1 = first
num2 = first
len1 = len(num1)
len2 = len(num2)
try:
num1 = int(first)
num2 = int(first)
except:
print("")
return "Error: Numbers must only contain digits."
if(num1/1000 > 10):
return "Error: Numbers cannot be more than four digits."
elif(num2/1000 > 10):
return "Error: Numbers cannot be more than four digits."
if(first!='+'):
if(first!='-'):
return "Error: Operator must be '+' or '-'."
else:
sum = num1 - num2
sign = '-'
else:
sum = num1 + num2
sign = "+"
str_ans = str(sum)
len3 = len(str_ans)
if len1 > len2 :
sp2 = " "*(len1-len2+1)
dash = "-"*(len1+2)
sp3 = " "*(len1+2-len3)

if(i==val[len(val)-1]):
fline += f"  {num1}"
sline += f"{sign}{sp2}{num2}"
dline += f"{dash}"
if chk is True:
ansline += f"{sp3}{sum}"

else:
fline += f"  {num1}    "
sline += f"{sign}{sp2}{num2}    "
dline += f"{dash}    "
if chk is True:
ansline += f"{sp3}{sum}    "
else:
sp1 = " "*(len2-len1+2)
dash = "-"*(len2+2)
sp3 = " "*(len2+2-len3)
if(i==val[len(val)-1]):
fline += f"{sp1}{num1}"
sline += f"{sign} {num2}"
dline += f"{dash}"
if chk is True:
ansline += f"{sp3}{sum}"
else:
fline += f"{sp1}{num1}    "
sline += f"{sign} {num2}    "
dline += f"{dash}    "
if chk is True:
ansline += f"{sp3}{sum}    "

# print(fline+"\n"+sline+"\n"+dline+"\n"+ansline)
result = f"{fline}\n{sline}\n{dline}\n{ansline}"
return result
``````

** error image**

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

Challenge: Arithmetic Formatter