def bracket_level(text, open={'(', '[', '{'}, close={')', ']', '}'}):
    """Return 0 if string contains balanced brackets or no brackets."""
    level = 0
    for c in text:
        if c in open:
            level += 1
        elif c in close:
            level -= 1
    return level
def bracket_level ( text , open = { '(' , '[' , '{' } , close = { ')' , ']' , '}' } ) : level = 0 for c in text : if c in open : level += 1 elif c in close : level -= 1 return level
Return 0 if string contains balanced brackets or no brackets.