# Scientific Computing with Python Projects - Arithmetic Formatter

### Tell us what’s happening:

Is it possible to organize my code something like below? I tried that but it is not working. Somehow?

print(f’\n{operand1s:>{string-1}}\n{operator}{operand2s:>{string-2}}\n{string}\n{results:>{string-1}}')

``````def arithmetic_arranger(problems, show_answers=False):
for problem in problems:
problem = problem.split()
operand1 = int(problem[0])
operand2 = int(problem[2])
operator = problem[1]
if len(problems) > 5:
print('Error: Too many problems.')
elif operand1 > 9999 or operand2 > 9999:
print('Error: Numbers cannot be more than four digits.')
result = " "
elif show_answers == True and operator == '+':
result = operand1 + operand2
elif show_answers == True and operator == '-':
result = operand1 - operand2
else:
print("Error: Operator must be '+' or '-'.")
operand1s = str(operand1)
operand2s = str(operand2)
results = str(result)
string_count = 2 + max(len(operand1s), len(operand2s))
string = string_count * '-'

print(f'\n{operand1s:>5}\n{operator}{operand2s:>4}\n{string}\n{results:>5}')

print(f'\n{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/124.0.0.0 Safari/537.36`