Hi! Why am I getting this error?

``````line 33
else :
SyntaxError: invalid syntax
``````

My code so far:

``````def arithmetic_arranger(problems, *k):
arranged_problems = ""
(line1, line2, line3, line4) = ("", "", "", "")

if len(problems) > 5 :
arranged_problems = "Error: Too many problems."
else :
for i in  range(len(problems)) :
operation = problems[i].split()

try:
operation = int(operation)  # termo 1
operation = int(operation)  # termo 2
except:
arranged_problems = "Error: Numbers must only contain digits."
break

if len(operation) > 4 or len(operation) > 4 :
arranged_problems ="Error: Numbers cannot be more than four digits."
break

if operation == "+" : operation.append(operation + operation)
elif operation == "-" : operation.append(operation - operation)
else:
arranged_problems = "Error: Operator must be '+' or '-'."
break

if len(str(operation)) > len(str(operation)):
line1 = line1 + operation.rjust(2+len(operation)) + "    "
line2 = line2 + operation + " " + operation.right(len(operation)) + "    "
line3 = line3 + (2 + len(operation))*"-" + "    "
line4 = line4 + operation.right(2+len(operation) + "    "
else : # <<<<< line 33 ERROR >>>#
line1 = line1 + operation.rjust(2+len(operationo)) + "    "
line2 = line2 + operation + " " + operation + "    "
line3 = line3 + (2 + len(operation))*"-" + "    "
line4 = line4 + operation.right(2+len(operation)) + "    "

if arranged_problems == "":
if k == False :
arranged_problems = line1 +"\n"+ line2 +"\n"+line3
elif k == True :
arranged_problems = line1 +"\n"+ line2 +"\n"+line3+"\n"+line4
else:
k = False
arranged_problems = line1 +"\n"+ line2 +"\n"+line3

return arranged_problems
``````

Thanks in advance You haven’t closed the bracket…

1 Like

Wow, cant believe I missed it
Thanks