Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def balanced_brackets(brac):
  2. s = Stack()
  3. brackets = '(' ')' '<' '>'
  4. while not brac.is_empty():
  5. a = s.peak(brac)
  6. if not a == brackets:
  7. s.pop(a)
  8. elif a == '(' and ')':
  9. s.pop(a)
  10. elif a == '<' and '>':
  11. s.pop(a)
  12. else:
  13. return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement