Advertisement
rockettt

последовательность ()

May 15th, 2024
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6. def check2(s):
  7.     stack3 = []
  8.     pod_mat = {')': '(', '}': '{', ']': '['}
  9.     for i in s:
  10.         if i in pod_mat.values():
  11.             stack3.append(i)
  12.         elif i in pod_mat:
  13.             if not stack3 or stack3.pop() != pod_mat[i]:
  14.                 return False
  15.         else:
  16.             return False
  17.     return not stack3
  18.  
  19. s = input()
  20. if (check2(s)) == True:
  21.     print("yes")
  22. else:
  23.     print("no")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement