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)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: