def paren_change ( inputstring , opens = opens , closes = closes ) : count = 0 for c in inputstring : if c in opens : # open parens/brackets/braces count -= 1 elif c in closes : # close parens/brackets/braces count += 1 return count
count the number of open brackets in a string using python
Determine the parenthetical change of level ( num closes - num opens ) .
def paren_change(inputstring, opens=opens, closes=closes):
    """Determine the parenthetical change of level (num closes - num opens)."""
    count = 0
    for c in inputstring:
        if c in opens:  # open parens/brackets/braces
            count -= 1
        elif c in closes:  # close parens/brackets/braces
            count += 1
    return count