input:                             from typing import List
  
  
  def evaluate_postfix(expression: str) -> int:
      """Evaluates a given postfix expression and returns the result.
      
      >>> evaluate_postfix("2 3 + 4 5 * *")
      46
      >>> evaluate_postfix("5 3 1 * + 4 -")
      4
      """
      stack = []
      for element in expression.split():
          if element.isdigit():
              stack.append(int(element))
          else:
              val2 = stack.pop()
              val1 = stack.pop()
              if element == '+':
                  stack.append(val1 + val2)
              elif element == '-':
                  stack.append(val1 - val2)
              elif element == '*':
                  stack.append(val1 * val2)
              elif element == '/':
                  stack.append(val1 / val2)
      return stack[0]
output:     stack = []
      for element in expression.split():
          if element.isdigit():
              stack.append(int(element))
          else:
              val2 = stack.pop()
              val1 = stack.pop()
              if element == '+':
                  stack.append(val1 + val2)
              elif element == '-':
                  stack.append(val1 - val2)
              elif element == '*':
                  stack.append(val1 * val2)
              elif element == '/':
                  stack.append(val1 / val2)
      return stack[0]