Tell us what’s happening:
I dont understand why, when i run the tests, they are not approved. at lest the Error, if there are more than 5 inputs(line 16) are supposed to be accepted as correct or arent they? Maybe do I simply not understand how this test works.
Im sorry for the variable names, Im German and thanks for anyone who replies.
Your code so far
def arithmetic_arranger(problems, show_answers=False):
line_two = ""
line_one = ""
line_three = ""
line_four = ""
print(type(len(problems)))
if len(problems)> 5:
print("Error: Too many problems.")
else:
for i in range(len(problems)) :
Leer_zeichen = ""
number_one = problems[i].split()[0]
number_two = problems[i].split()[2]
Rechen_zeichen = problems[i].split()[1]
number_four = ""
if show_answers == True:
number_four = str(int(number_one) + int(number_two))
max_breite = max(len(number_one),len(number_two))
for x in range(max_breite):
Leer_zeichen += "-"
line_one += f"{number_one:>{2+max_breite}} "
line_two += f"{Rechen_zeichen} {number_two:>{max_breite}} "
line_three += f"--{Leer_zeichen:>{max_breite}} "
line_four += f"{number_four:>{2+max_breite}} "
return(f"{line_one}\n{line_two}\n{line_three}\n{line_four}")
print(f'\n{arithmetic_arranger(["32 + 698", "3801 - 23", "45 + 43", "123 + 49"], True)}')
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Challenge Information:
Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project