# def check_brackets(s):
#     stack = []
#     for x in range(len(s)//2):
#         if s[x] != s[-1-x]:
#             return False

#     return True

# print(check_brackets("({[]})"))


def check_brackets(s):
    stack = []

    for ch in s:
        if ch == '(' or ch == '[' or ch == '{':
            stack.append(ch)
        elif ch == ')':
            stack != '('
            return False
        elif ch == ']':
            stack != '['
            return False
        elif ch == '}':
            stack != '{'
            return False
        
print(check_brackets("([])"))

Embed on website

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