Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Brackets by PiotrStachowiak
def checkio(expression):
a=1
open = ['(','[','{']
close = [')',']','}']
brackets = []
for i in expression:
if i == '(' or i == '[' or i == '{':
brackets.append(i)
if i == ')' or i == ']' or i == '}':
if len(brackets) == 0:
return False
x = close.index(i)
e = open[x]
if e != brackets.pop():
return False
if len(brackets) == 0:
return True
else:
return False
Nov. 18, 2016