Create a Python program that simulates a basic command-line calculator supporting addition, subtraction, multiplication, and division. The program should accept expressions in infix notation and use the Shunting Yard algorithm to convert them to postfix notation before evaluation. PLAINFORMAT
def calculator(expression):
    def precedence(op):
        if op == '+' or op == '-':
            return 1
        if op == '*' or op == '/':
            return 2
        return 0

    def apply_operator(operators, values):
        operator = operators.pop()
        right = values.pop()
        left = values.pop()
        if operator == '+':
            values.append(left + right)
        elif operator == '-':
            values.append(left - right)
        elif operator == '*':
            values.append(left * right)
        elif operator == '/':
            values.append(left / right)

    def greater_precedence(op1, op2):
        return precedence(op1) > precedence(op2)

    operators = []
    values = []
    i = 0
    while i < len(expression):
        if expression[i] == ' ':
            i += 1
            continue
        if expression[i] >= '0' and expression[i] <= '9':
            j = i
            while j < len(expression) and (expression[j] >= '0' and expression[j] <= '9'):
                j += 1
            values.append(int(expression[i:j]))
            i = j
        else:
            while (operators and operators[-1] != '(' and
                   greater_precedence(operators[-1], expression[i])):
                apply_operator(operators, values)
            operators.append(expression[i])
            i += 1

    while operators:
        apply_operator(operators, values)

    return values[0]

if __name__ == "__main__":
    expression = input("Enter the expression: ")
    result = calculator(expression)
    print("Result:", result)