Tell us what’s happening:
I understand if the second number has more digits, there should only be one space of separation, but if it isn’t, what is the criteria?? I really can’t understand and i think this is the only thing that isn’t letting me pass the more basic tests
Your code so far
def arithmetic_arranger(problems, show_answers=False):
data = [[], [], []]
solution = []
for problem in problems:
elements = problem.split(' ')
if len(elements[2]) >= len(elements[0]):
second = f'{elements[1]} {elements[2]}'
else:
second = f'{elements[1]}{" " * (len(elements[0]) - 1)}{elements[2]}'
data[0].append(' '*(len(second) - len(elements[0])) + elements[0])
data[1].append(second)
data[2].append('-' * len(second))
solution.append(' '.join(data[0]))
solution.append(' '.join(data[1]))
solution.append(' '.join(data[2]))
return '\n'.join(solution)
print(f'\n{arithmetic_arranger(["3801 - 2", "123 + 49"])}')
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Challenge Information:
Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project