def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

def multiply(x, y):
    return x * y

def divide(x, y):
    if y == 0:
        raise ZeroDivisionError("Division by zero is not allowed.")
    return x / y

def calculator():
    while True:
        try:
            num1 = float(input("Enter the first number: "))
            operation = input("Enter the operation (+, -, *, /) or 'exit' to quit: ")
            num2 = float(input("Enter the second number: "))
            
            if operation == 'exit':
                print("Exiting calculator.")
                break

            if operation not in ['+', '-', '*', '/']:
                raise ValueError("Invalid operation. Please enter '+', '-', '*', or '/'.")

            if operation == '+':
                result = add(num1, num2)
            elif operation == '-':
                result = subtract(num1, num2)
            elif operation == '*':
                result = multiply(num1, num2)
            elif operation == '/':
                result = divide(num1, num2)

            print("Result:", result)

        except ValueError as ve:
            print("Error:", ve)
        except ZeroDivisionError as zde:
            print("Error:", zde)

    calculator()