# Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project

### Tell us what’s happening:

I’ve tried this code in at least 3 different Python interpreters, but I don’t see where the [Objects] are coming from. Should I approach the problem differently?"

### Your code so far

``````def arithmetic_arranger(problems, show_answers=False):

res=True
if len(problems)>5:
return print('Error: Too many problems.')
res=False
for op in problems:
if op.find('/')>0 or op.find('*')>0:
return print("Error: Operator must be '+' or '-'.")
res=False
op1 = op.split()
for num in op1:
if not num.isdigit() and not (num == '+' or num == '-'):
return print('Error: Numbers must only contain digits.')
res=False
elif len(num)>4:
res=False
return print('Error: Numbers cannot be more than four digits.')
for i in problems:
b=i.split()
if len(b[0])>len(b[2]):
max_length=len(b[0])
print(f"{b[0]:>{max_length+1}}", end="   ")
else:
max_length=len(b[2])
print(f"{b[0]:>{max_length+1}}", end="   ")
print()
for i in problems:
b=i.split()
if len(b[0])>len(b[2]):
max_length=len(b[0])
print(f"{b[1]}{b[2]:>{max_length}}", end="   ")
else:
max_length=len(b[2])
print(f"{b[1]}{b[2]:>{max_length}}", end="   ")
print()
for i in problems:
b=i.split()
if len(b[0])>len(b[2]):
max_length=len(b[0])
print(f"{'-' * (max_length + 1)}", end="   ")
else:
max_length=len(b[2])
print(f"{'-' * (max_length + 1)}", end="   ")

if res and show_answers:
print()
for i in problems:
resu=0
b=i.split()
for j in range(0,3,2):
if (b[1])=='+':
resu+=int(b[j])
else:
if j==0:
resu+=int(b[j])
else:
resu-=int(b[j])

if len(b[0])>len(b[2]):
max_length=len(b[0])
print(f" {resu:>{max_length}}", end="   ")
else:
max_length=len(b[2])
print(f" {resu:>{max_length}}", end="   ")
return ''
else:
return ''

print(f'\n{arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])}')
``````

### Your browser information:

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

### Challenge Information:

Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project

I’m not sure what you’re asking exactly but your function should `return` the output string, not print it.

Now i get it, thanks

1 Like