Last active
August 11, 2021 09:17
-
-
Save KAnanev/e917b5d84f5d2b33707686afc2e7888c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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