fork download
  1. import sys
  2. input = sys.stdin.readline
  3.  
  4. while True:
  5. sentence = input().strip('\n')
  6. if sentence == '.':
  7. break
  8. snt_list = []
  9. result = []
  10. print_sth = ''
  11. for i in sentence:
  12. if (ord(i) < 65) or (90 < ord(i) < 97) or (ord(i) > 122) or (i != ' '):
  13. snt_list.append(i)
  14. for j in snt_list:
  15. if j == '(' or j == '[':
  16. result.append(j)
  17. elif j == ')':
  18. if len(result) != 0 and result[-1] == '(':
  19. result.pop()
  20. else:
  21. if print_sth == '':
  22. print_sth += 'no'
  23. elif j == ']':
  24. if result[-1] == '[':
  25. result.pop()
  26. else:
  27. if print_sth == '':
  28. print_sth += 'no'
  29. if len(result) == 0:
  30. if print_sth == '':
  31. print_sth += 'yes'
  32. print(print_sth)
Runtime error #stdin #stdout #stderr 0.14s 25952KB
stdin
SO ( HI )].
.
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 24, in <module>
IndexError: list index out of range