Advertisement
simeonshopov

Matching Brackets

Mar 11th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. info = list(input())
  2.  
  3. stack = []
  4.  
  5. for x in range(len(info)):
  6.     if info[x] == '(':
  7.         stack.append(x)
  8.     if info[x] == ')':
  9.         start = stack.pop()
  10.         result = info[start:x + 1]
  11.         print(''.join([str(x) for x in result]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement