2 failures - Python Project - Arithmetic Formatter

Hello everyone,
I don’t know what is wrong with my code, but I’m getting these two messages:

You can see my code here (repl.it)
Or here (GitHub)
If I get any help I’ll be grateful.

Hi @anabeatriz, you might want to edit your post and change the forum to the Python forum to get more eyes on.

1 Like

Done. Thank you.

In your code here for the problems with answers:

	if mostrar:
		resposta = [eval(r) for r in problems]
		# Primeiro numero
		for p in primeiro:
			print(p.rjust(5), "    ", end=" ")
		# Operador e segundo numero
		for os in range(len(operador)):
			print(operador[os], segundo[os].rjust(3), "    ", end=" ")
		# Hifens
		for m in maxLen:
			if m == 1:
				print("-" * (m + 4), "    ", end=" ")
			elif m == 2:
				print("-" * (m + 3), "    ", end=" ")
			elif m == 3:
				print("-" * (m + 2), "    ", end=" ")
			elif m == 4:
				print("-" * (m + 1), "    ", end=" ")
		# Resposta
		for r in resposta:
			print(str(r).rjust(5), "    ", end=" ")

you are printing the problems and solutions. arithmetic_arranger() should return the arranged problems and solutions as a string. Your printed output looks correct, so it should just be a matter of changing all the print() statements to building up a string in a variable and then returning the string. You will also need to do the same thing in for the part that just arranges the problems without solutions.

Good luck.

1 Like

@jeremy.a.gray Thank you. I’ll modify my code.

@jeremy.a.gray I changed my code, but these two messages are still appearing. :confused:

now you have different errors

there is also a diff part that compares the expected output with yours:
the lines starting with + are the expected output, those starting with - is your output and the lines starting with ? mark the differences between them

1 Like

@ieahleen Ok. I didn’t know that. Thank you.

@ieahleen I don’t know what’s wrong yet. :bowing_woman:t2:

do you understand that the diff is poining to the “invisible” characters at the end of each line?

@ieahleen the 4 white spaces? I need them because of the rules of the challenge.

where does it say you need them at the end of a line?

“There should be four spaces between each problem.”

between each problem, there is not a problem at the end of the line

1 Like

I accomplished the challenge. Thank you!