# Arithmetic Formatter Noobie

Tell us what’s happening:
I cant seem to get the problems side by side, ive look at many articles and I still cant see what I am doing wrong. I know the code is correct, besides the fact that the problems do go side by side

``````def arithmetic_arranger(Mproblems, solver= False):
fnum_list = ''
operators_list = ''
snum_list = ''
lines = ''
solution = ''

# Limiting the problem to just 5
if len(Mproblems) > 5:
print('Error: Too many problems.')
#Loop
for problems in Mproblems:
problems = problems.split()
fnum_list = problems
operators_list = problems
snum_list = problems
#Check if its a digit & Check the length of number is not greater than 5
if fnum_list.isdigit() and snum_list.isdigit():
if len(fnum_list) > 4 or len(snum_list) > 4:
print('Error: Numbers cannot be more than four digits.')
#Checking + or - only
if operators_list == '+':
solution = int(fnum_list) + int(snum_list)
elif operators_list == '-':
solution = int(fnum_list) - int(snum_list)
else:
print('Error: Operator must be + or - ')
#Defining the distance
distance = max(len(fnum_list) , len(snum_list)) + 2
#Structure of Math problems
topnum = str(fnum_list.rjust(distance))
botnum = str(operators_list.ljust(0)) + ' ' + str(snum_list.rjust(distance - 2))
solution_line = str(solution)
lines = '-' * distance
#Chekcing solver
if solver:
solution = topnum + "\n" + botnum + "\n" + lines + "\n" + solution_lin
return solution
else:
solution = topnum + "\n" + botnum + "\n" + lines
return solution
print(solution)

arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])
``````

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

Challenge: Arithmetic Formatter

Arithmetic Formatter - Replit
Here is the proper layout of the code

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

1 Like

As you use these variables in your final result, you need to keep adding to these variables during each iteration