Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = input()
- st = []
- pairs = {
- '(': ')',
- '[': ']',
- '{': '}',
- }
- res = True
- for i in range(len(s)):
- if s[i] in pairs:
- st.append(s[i])
- elif st and pairs[st[-1]] == s[i]:
- st.pop()
- else:
- res = False
- break
- if res and not st:
- print('yes')
- else:
- print('no')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement