# Scientific Computing with Python Projects - Arithmetic Formatter - DhiK9iueAd1z4TwGeQnMk

Tell us what’s happening:
So I did the arithmetic formatter exercise and I post the link in the Solution Link box but there is no feedback except a tick next to the project name on the course page.

Does it mean I did it correctly?

def arithmetic_arranger(list1):
# error 1
if len(list1) > 5:
print("Error: Too many problems.")

# error 2
for i in list1:
if i.split()[1] in "+-":
continue
else:
print("Error: Operator must be '+' or '-'.")
# error 3
if not i.split()[0].isdigit() and i.split()[2].isdigit():
print("Error: Numbers must only contain digits.")
# error 4
for j in i.split():
if len(j) <= 4:
continue
else:
print("Error: Numbers cannot be more than four digits.")
break

# prepare operand and operator list
operands_top = []
operators = []
operands_bot = []
dashes = []
results = []

# seperating operands and operators from the given list of strings
# formatting lists' elements with " "
for i in list1:
length = max(len(i.split()[0]), len(i.split()[2])) + 2
operands_top.append(i.split()[0].rjust(length, " "))
operators.append(i.split()[1])
operands_bot.append(i.split()[2].rjust(length - 1, " "))
dashes.append("-" * length)

# print(operands_top)
# print(operators)
# print(operands_bot)
# print(dashes)

# calculate the resutls
# formatting list's element with " "
for i in range(len(list1)):
length = len(dashes[i])
top = operands_top[i]
bot = operands_bot[i]
if operators[i] == "+":
results.append(str(int(top) + int(bot)).rjust(length, " "))
else:
results.append(str(int(top) - int(bot)).rjust(length, " "))

# print(results)

second_row = []
for i in range(len(list1)):
second_row.append(operators[i] + operands_bot[i])

# print(second_row)

first_row = "    ".join(operands_top)
second_row1 = "    ".join(second_row)
third_row = "    ".join(dashes)
forth_row = "    ".join(results)

print(first_row)
print(second_row1)
print(third_row)
print(forth_row)

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

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: Scientific Computing with Python Projects - Arithmetic Formatter