Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text = input()
- stack = []; match = 0
- for i in text:
- if i == '(' or i == '{' or i == '[':
- stack.append(i)
- elif len(stack) > 0:
- pop = stack.pop()
- if ord(i) == ord(pop)+1 or ord(i) == ord(pop)+2:
- match += 1
- if match == len(text)/2:
- print('Yes')
- else:
- print('No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement