```
import re
def arithmetic_arranger(problems, solve = False):
if(len(problems) > 5):
return "Error:Too many Problems"
first = ""
second = ""
line = ""
sumx = ""
string = ""
for problem in problem:
if(re.search("[^\$0-9.+-]", problem)):
if(re.search("[/]", problem) or re.search ("*", problem )):
return "Error: Operator must be '+' or '-'."
return "Error:Numbers must be only contains digits"
firstnumber = problem.split(" ")[0]
operator = problem.split(" ")[1]
secondnumber = problem.split(" ")[2]
if(len(firstnumber) >= 5 or len(secondnumber) >= 5):
return "Numbers cant be more than 4 digits"
sum = ""
if(operator == "+"):
sum = str(int(firstnumber) + int(secondnumber))
elif(operator == "-"):
sum = str(int(firstnumber) - int(secondnumber)
length = max(len(firstnumber), len(secondnumber))
top = str(firstnumber).rjust(length)
bottom = operator + str(secondnumber).rjust(length - 1)
line = ""
res = str(sum).rjust(length)
for s in range(length):
line += "-"
if problem != problems(-1):
first += top + " "
second += bottom + " "
lines += line + " "
sumx += res + " "
else:
first += top
second += bottom
lines += line
sumx += res
if solve:
string = first + "\n" + second + "\n" + lines + "\n" + sumx + "\n"
else:
string = first + "\n" + second + "\n" + lines
return string
```

Welcome to FCC.

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

It would also be useful to provide a description of what is not working or what error you are seeing.

It seems you are returning on,y if `solve`

is false, any reason there?

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