summaryrefslogtreecommitdiff
path: root/progs/unparsable_programs/a538.py
blob: 7ae9d78c00b71647b40f4eab486e1575fd0b3772 (plain)
1
2
3
4
5
6
7
8
def is_valid_parenthese( str1):
        stack, pchar = [], {"(": ")", "{": "}", "[": "]"}
        for parenthese in str1:
            if parenthese in pchar:
                stack.append(parenthese)
            elif len(stack) == 0 or pchar[stack.pop()] != parenthese:
                return False
        return len(stack) == 0