Programing/자료구조, Algorithm

programmers - 올바른괄호[level2] - python

r00t0k 2019. 1. 26. 02:49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def solution(s):
    lst =[]
    if s.count('('== s.count(')'and s[0== '(' and s[-1== ')':
        for i in range(0len(s)):
            if s[i] == '(':
                lst.append('(')
            elif s[i] == ')':
                try:
                    lst.pop()
                except:
                    print('except')
                    return False
    else:
        return False
    return True
cs