Advertisement
Guest User

Untitled

a guest
Jun 18th, 2010
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. >>> def balance(tobalance):
  2. ...     if not tobalance:
  3. ...         return True
  4. ...     if tobalance in ["(", ")", ")("]:
  5. ...         return False
  6. ...     return balance(tobalance.replace("()", ""))
  7. ...
  8. >>> balance("((()))")
  9. True
  10. >>> balance("((())))")
  11. False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement