human
Solve in Python:
Return the result of evaluating a given boolean expression, represented as a string.
An expression can either be:

"t", evaluating to True;
"f", evaluating to False;
"!(expr)", evaluating to the logical NOT of the inner expression expr;
"&(expr1,expr2,...)", evaluating to the logical AND of 2 or more inner expressions expr1, expr2, ...;
"|(expr1,expr2,...)", evaluating to the logical OR of 2 or more inner expressions expr1, expr2, ...

 
Example 1:
Input: expression = "!(f)"
Output: true

Example 2:
Input: expression = "|(f,t)"
Output: true

Example 3:
Input: expression = "&(t,f)"
Output: false

Example 4:
Input: expression = "|(&(t,f,t),!(t))"
Output: false

 
Constraints:

1 <= expression.length <= 20000
expression[i] consists of characters in {'(', ')', '&', '|', '!', 't', 'f', ','}.
expression is a valid expression representing a boolean, as given in the description.
assistant
#Here is the Python program you requested.

class Solution:
    def parseBoolExpr(self, expression: str) -> bool:
        stack = []
        for ch in expression:
            if ch == ',':
                continue
            if ch != ')':
                stack.append(ch)
            else:
                temp = ''
                while stack[-1] != '(':
                    temp += stack.pop()
                stack.pop()
                if stack[-1] == '&':
                    res = 't' if temp.count('f') == 0 else 'f'
                elif stack[-1] == '|':
                    res = 'f' if temp.count('t') == 0 else 't'
                else:
                    res = 't' if temp == 'f' else 'f'
                stack[-1] = res
        return True if stack[-1] == 't' else False