Esempio n. 1
0
def is_paren_balanced(paren_string):
	s = Stack()
	is_balanced = True
	index = 0

	while index < len(paren_string) and is_balanced:
		paren = paren_string[index]
		if paren in "({[":
			s.push(paren)
		else:
			if s._isempty():
				is_balanced = False
			else:
				top = s.pop()
				if not is_match(top,paren):
					is_balanced = False
		index += 1
	


	if s._isempty() and is_balanced :
		return True
	else:
		return False