Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Brackts solution in Clear category for Brackets by CyrylWilczek
def checkio(expression):
left_cut = []
brackets = ["{", "(", "["]
if expression.count("{") == expression.count("}") and expression.count("(") == expression.count(")") and expression.count("[") == expression.count("]"):
for char in expression:
if char in brackets:
left_cut.append(char)
elif char =="}":
if left_cut[-1] == "{":
del left_cut[-1]
else:
return False
elif char ==")":
if left_cut[-1] == "(":
del left_cut[-1]
else:
return False
elif char =="]":
if left_cut[-1] == "[":
del left_cut[-1]
else:
return False
return True
else:
return False
Jan. 6, 2018