fork download
  1. # 4949
  2. while True:
  3. sentence = str(input())
  4. stack = []
  5. if sentence == '.':
  6. print('yes')
  7. break
  8. else:
  9. for i in sentence:
  10. if i == '[' or i == '(':
  11. stack.append(i)
  12. elif i == ']':
  13. if stack[-1] == '[':
  14. stack.pop()
  15. else:
  16. print('no')
  17. break
  18. elif i == ')':
  19. if stack[-1] == '(':
  20. stack.pop()
  21. else:
  22. print('no')
  23. break
  24. else:
  25. if not stack: #break되지 않고 스택이 비어있는 상황
  26. print('yes')
  27. else:
  28. print('no')
Runtime error #stdin #stdout #stderr 0.16s 25352KB
stdin
].
.
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 13, in <module>
IndexError: list index out of range