God i can not do formatting properly, to be precise, returning side by side results.

And i have problem with return statement and logic. inside my code on every variable i made detail comment. pls help.

```
def arithmetic_arranger(problems, show_solutions=True):
#in variable numbers_sorted i split problems into first number, operator, and second number
numbers_sorted =[]
#this should be returned as last variable. this is problem
final_product=""
if len(problems) >5:
'Error: Too many problems.'
#spliting problems into number1 i[0] and number2 i[2] and operator i[1]
for i in problems:
numbers_sorted.append(i.split(" "))
for i in numbers_sorted:
if i[0].isnumeric()==False:
return "Error: Numbers must only contain digits."
if i[2].isnumeric()==False:
return "Error: Numbers must only contain digits."
if i[1] !="+" and i[1]!="-":
return "Error: Operator must be '+' or '-'."
if len(i[0]) >=5 or len(i[2]) >=5:
return "Error: Numbers cannot be more than four digits."
#in results i do arimetics , first number + or minus second number
result=""
if i[1]=="+":
result= int(i[0])+int(i[2])
elif i[1]=="-":
result= int(i[0])-int(i[2])
#this is for rjust, no problem with this
width = max(len(i[0]), len(i[2]))+2
#top line, first number and rjust
top_line= i[0].rjust(width)
#operator + second number.rjust
middle_line= i[1] +i[2].rjust(width-1)
#this is no problem
only_line=""
#and final line is just number from result converted to string and r.justed so it can easly be printed
final_line = str(result).rjust(width)
for z in range(width):
only_line +="-"
#HERE ARE PROBLEMS;
#first problem is that is no way how i can figure how to get results side by side..i got ok rjust, lines,
#but they are printed one bellow other. pls help
#second problem si -RETURN -how is this function working? when i put for example "print final product" i got what
#i want.. when i want to use "return" i dont understand.. where ever i move itd, it is just prints nothing or confusion.
#so how to make return to work properly, and how to format those numbers side by side..
if show_solutions:
final_product= top_line +"\n" +middle_line +"\n"+only_line +"\n"+final_line
print(final_product)
else:
final_product =top_line +"\n" +middle_line +"\n"+only_line
return(final_product)
```