def match_paren(parens):
 stack = Stack()
 for b in parens:
  if (b == '('):
   stack.push(1)
  elif (not stack.isEmpty()):
   stack.pop()
  else:
   return False
 return stack.isEmpty()

def match_paren ( parens ) : stack = Stack ( ) for b in parens : if ( b == '(' ) : stack . push ( 1 ) elif ( not stack . isEmpty ( ) ) : stack . pop ( ) else : return False return stack . isEmpty ( )
returns true or false if parenthesis expression passed is matching .