Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> def balance(tobalance):
- ... if not tobalance:
- ... return True
- ... if tobalance in ["(", ")", ")("]:
- ... return False
- ... return balance(tobalance.replace("()", ""))
- ...
- >>> balance("((()))")
- True
- >>> balance("((())))")
- False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement