commands = "{[()()]}"
stack = []
bracket_map = {')': '(', '}': '{', ']': '['}
for char in commands:
if char in '({[':
stack.append(char)
elif char in ')}]':
if not stack or stack[-1] != bracket_map[char]:
result = False
break
stack.pop()
else:
result = not stack
print(result)
To embed this project on your website, copy the following code and paste it into your website's HTML: