Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def remove_unbalance(s):
- last_open = s.rfind("(")
- last_close = s.rfind(")")
- return s[:last_open] if last_open > last_close else s
- print(remove_unbalance("aaaa(bbbb)(ccccc"))
- # aaaa(bbbb)
- print(remove_unbalance("esdfd((esdf)(esdf"))
- # esdfd((esdf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement