Tell us what’s happening:
Help idk if I am on the right track or not. I am not sure how to continue. I am sorry if this question is too basic, I just started learning how to code this week. Thanks in advance!
Your code so far
def arithmetic_arranger(problems, show_answers=False):
if len(problems) > 5:
return 'Error: Too many problems.'
for problem in problems:
prob = problems.split()
if prob[1] == '*' or prob[1] == '/':
return "Error: Operator must be '+' or '-'."
if prob[0].isdigit() or prob[2].isdigit() == False:
return"Error: Numbers must only contain digits."
if (prob[0]) or len(prob[2]) > 4:
return "Error: Numbers cannot be more than four digits."
else:
if prob[1] == '+':
answer = prob[0] + prob[2]
else:
if len(prob[2]) > len(prob[0]):
answer = prob[2] - prob[0]
else:
answer = prob[0] - prob[2]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build an Arithmetic Formatter Project - Build an Arithmetic Formatter Project