Skip to content

Instantly share code, notes, and snippets.

@hickford hickford/gist:792036
Created Jan 23, 2011

What would you like to do?
test if brackets in string are well-nested
def f(word):
open = 0
for x in word:
if x == "(":
open += 1
elif x == ")":
open += -1
if open < 0:
return False
return open==0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.