while top_token !'('postfix_list append(top_tokentop_token op_stack pop(elsewhile (not op_stack is_empty()and (prec[op_stack peek()>prec[token])postfix_list append(op_stack pop()op_stack push(token while not op_stack is_empty()postfix_list append(op_stack pop()return join(postfix_list print(infix_to_postfix(" ")print(infix_to_postfix(" )") few more examples of execution in the python shell are shown below infix_to_postfix(" )"' *infix_to_postfix(" "' *infix_to_postfix(" "' +postfix evaluation as final stack examplewe will consider the evaluation of an expression that is already in postfix notation in this casea stack is again the data structure of choice howeveras you scan the postfix expressionit is the operands that must waitnot the operators as in the conversion algorithm above another way to think about the solution is that whenever an operator is seen on the inputthe two most recent operands will be used in the evaluation to see this in more detailconsider the postfix expression as you scan the expression from left to rightyou first encounter the operands and at this pointyou are still unsure what to do with them until you see the next symbol placing each on the stack ensures that they are available if an operator comes next in this casethe next symbol is another operand soas beforepush it and check the next symbol now we see an operatorthis means that the two most recent operands need to be used in multiplication operation by popping the stack twicewe can get the proper operands and then perform the multiplication (in this case getting the result we can now handle this result by placing it back on the stack so that it can be used as an operand for the later operators in the expression when the final operator is processedthere will be only one value left on the stack pop and return it as the result of the expression figure shows the stack contents as this entire example expression is being processed the stack abstract data type