Complete the code to push an operator onto the stack.
stack.[1](ch)In Python, to add an element to the end of a list (used as a stack), we use append.
Complete the code to pop the top element from the stack.
top = stack.[1]()To remove and get the last item from a list (stack), use pop().
Fix the error in the precedence function to return correct precedence for '+' operator.
if op == '[1]': return 1
The '+' operator has precedence 1 in this function.
Fill both blanks to correctly check operator precedence and decide stack pop.
while stack and precedence(stack[-1]) [1] precedence(ch): postfix += stack.[2]()
We pop from stack while top has higher or equal precedence, so use '>=' and pop().
Fill all three blanks to correctly handle closing parenthesis in the stack.
while stack and stack[-1] != [1]: postfix += stack.[2]() stack.[3]() # Remove '('
We pop until '(' is found, then pop '(' itself. So use '(' for comparison and pop() to remove.
