if you look at the browser’s console window (f12) you can see detailed error messages. If you can’t interpret them for yourself, please post them here for help.
please tell me what this means i’ve finished the course and didn’t use this f12 thing? what actually is it? And how come there isn’t an error on the terminal?
The function will return the correct conversion if the supplied problems are properly formatted, otherwise, it will return a string that describes an error that is meaningful to the user.
how do i explain code to myself for it to be effective and for me to see logic errors? I don’t want to just rely on you guys. When i explain it i just say what the code does, for example in my code i import regex to see a pattern in the code defining a function which has problems and show answer = false as the arguments
the ai on that link is crazy it responds like how you guys respond, it doesn’t give the answer it just questions lines of code and asks you what the logic behind it is
also could i ask why none of my stuff is passing the tests even tho i’m doing them??
import re
def arithmetic_arranger(problems, show_answers=False):
if len(problems) > 5:
return("Error: Too many problems")
for problem in problems:
print("this", problem)
parts = problem.split()
operand = problem.split()
operator = parts[1]
print("this", operand)
if operator != "+" and operator != "-":
print("Error: Operator must be '+' or '-'.")
if re.search(r'\D', operand[0]) or re.search(r'\D', operand[2]):
print("Error: Numbers must only contain digits.")
if len(operand[0]) > 4 or len(operand[2]) > 4:
print('Error: Numbers cannot be more than four digits.')
return problems
print(repr(f'\n{arithmetic_arranger(["32345 * 698", "3801 - 2", "45 + 43", "123 + 49"])}'))
print(repr(f'\n{arithmetic_arranger}(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"]'))