Hi, I am very new to coding and am struggling to understand my error messages in replit. The code works when I work on it when I haven’t defined it and am working on a single equation, but when I define it and put it onto replit the equation parts are not working and I’m not entirely sure why. Sorry if it’s simple, I am still new to this. Thanks in advance!

Here is the code:

```
def arithmetic_arranger(problems, solve = False):
if len(problems) > 5:
return "Error: Too many problems."
for problem in problems:
peices = problem.split()
# print(peices)
firstNumber = peices[0]
# check that firstNumber is only numbers
try:
int(firstNumber)
except:
return "Error: Numbers must only contain digits."
continue
#check that firstNumber is not more than four digits long
if len(firstNumber) > 4:
return "Error: Numbers cannot be more than four digits."
# print(firstNumber)
operator = peices[1]
# print(operator)
if not "+" or "-" in operator:
return "Error: Operator must be '+' or '-'."
secondNumber = peices[2]
# check that secondNumber is only numbers
try:
int(secondNumber)
except:
return "Error: Numbers must only contain digits."
continue
#check that secondNumber is not more than four digits long
if len(secondNumber) > 4:
return "Error: Numbers cannot be more than four digits."
# print(secondNumber)
# you need to find a way to change the print errors to return errors
# now doing the equation
firstLine = []
secondLine = []
thirdLine = []
fourthLine = []
for firstPosition in problems:
if len(firstNumber) > len(secondNumber):
firstLine.append(" "*2 + firstNumber)
else:
firstLine.append(" "*(len(secondNumber)-len(firstNumber) + 2)+ firstNumber)
# print(firstLine)
for secPosition in problems:
if len(firstNumber) > len(secondNumber):
secondLine.append(operator + " "*(len(firstNumber)-len(secondNumber) + 1) + secondNumber)
else:
secondLine.append(operator + " " + secondNumber)
# print(secondLine)
for dashes in problems:
if len(firstNumber) > len(secondNumber):
thirdLine.append("-"*(len(firstNumber) + 2))
else:
thirdLine.append("-"*(len(secondNumber) + 2))
# print(thirdLine)
for solution in problems:
if "+" in operator:
answer = int(firstNumber) + int(secondNumber)
else:
answer = int(firstNumber) - int(secondNumber)
answer = str(answer)
for ansPosition in problems:
if len(firstNumber) > len(secondNumber):
if len(firstNumber) > len(answer):
fourthLine.append(" "*(len(firstNumber)-len(answer)) + answer)
elif len(firstNumber) == len(answer):
fourthLine.append(" "*2 + answer)
else:
fourthLine.append(" "*(len(answer)-len(firstNumber)) + answer)
else:
if len(secondNumber) > len(answer):
fourthLine.append(" "*(len(secondNumber)-len(answer)) + answer)
elif len(secondNumber) == len(answer):
fourthLine.append(" "*2 + answer)
else:
fourthLine.append(" "*(len(answer)-len(secondNumber)) + answer)
# print(fourthLine)
arranged_problems = " ".join(firstLine) + "\n" + " ".join(secondLine) + "\n" + " ".join(thirdLine) + "\n" + " ".join(fourthLine)
print(arranged_problems)
return arranged_problems
```

Link to the code:

https://replit.com/@cayharris/boilerplate-arithmetic-formatter-6#arithmetic_arranger.py