are properly balanced in that not only does each opening symbol have corresponding closing symbolbut the types of symbols match as well compare those with the following strings that are not balancedthe simple parentheses checker from the previous section can easily be extended to handle these new types of symbols recall that each opening symbol is simply pushed on the stack to wait for the matching closing symbol to appear later in the sequence when closing symbol does appearthe only difference is that we must check to be sure that it correctly matches the type of the opening symbol on top of the stack if the two symbols do not matchthe string is not balanced once againif the entire string is processed and nothing is left on the stackthe string is correctly balanced the python program to implement this is shown below the only change appears in line where we call helper functionmatchesto assist with symbol-matching each symbol that is removed from the stack must be checked to see that it matches the current closing symbol if mismatch occursthe boolean variable balanced is set to false import stack as previously defined completed extended par_checker for[,{,(,),}, def par_checker(symbol_string) stack(balanced true index while index len(symbol_stringand balancedsymbol symbol_string[indexif symbol in "([{" push(symbolelseif is_empty()balanced false elsetop pop(if not matches(topsymbol)balanced false index index basic data structures