matching parentheses and html tags in this subsectionwe explore two related applications of stacksboth of which involve testing for pairs of matching delimiters in our first applicationwe consider arithmetic expressions that may contain various pairs of grouping symbolssuch as parentheses"(and ")braces"{and "}brackets"[and "]each opening symbol must match its corresponding closing symbol for examplea left bracket"[,must match corresponding right bracket"],as in the expression [( + )-( + )the following examples further illustrate this conceptcorrect)()){([)])correct(()()){([)])})incorrect)()){([)])incorrect({])incorrectwe leave the precise definition of matching group of symbols to exercise - an algorithm for matching delimiters an important task when processing arithmetic expressions is to make sure their delimiting symbols match up correctly code fragment presents python implementation of such an algorithm discussion of the code follows def is matched(expr) """return true if all delimiters are properly matchfalse otherwise ""opening delimiters lefty ({respective closing delims righty )} arraystack for in expr if in lefty push(cpush left delimiter on stack elif in righty if is empty) return false nothing to match with if righty index( !lefty index( pop)) return false mismatched were all symbols matched return is emptycode fragment function for matching delimiters in an arithmetic expression