-- coding:utf-8 --

class Parenthesis: def chkParenthesis(self, A, n): # write code here l = 0 for i in range(n): c = A[i] if c == '(': l+=1 elif c == ')': l=l-1 else: return False if l == 0: return True else: return False