Skip to content

Instantly share code, notes, and snippets.

@KAnanev
Last active August 11, 2021 09:17
Show Gist options
  • Save KAnanev/e917b5d84f5d2b33707686afc2e7888c to your computer and use it in GitHub Desktop.
Save KAnanev/e917b5d84f5d2b33707686afc2e7888c to your computer and use it in GitHub Desktop.
def bool_str(str_):
list_ = list(str_)
tmp_list = []
if list_ and list_[0] != ']' and list_[-1] != '[':
for item in list_:
if item == '[':
tmp_list.append(item)
elif item == ']' and tmp_list[-1] == '[':
tmp_list.pop()
if not tmp_list:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment