프로그래머스 연습문제 -올바른괄호(level2)
def solution(s):
answer = True
open = []
for i in s:
if i == '(':
open.append(i)
else:
if len(open)==0:
answer = False
break
else:
open.pop()
if len(open) != 0:
answer = False
return answer
def is_pair(s):
st = list()
for c in s:
if c == '(':
st.append(c)
if c == ')':
try:
st.pop()
except IndexError:
return False
return len(st) == 0