def calculator():
    while True:
        try:
            num1 = float(input("Enter the first number: "))
            operator = input("Enter the operator (+, -, *, /): ")
            num2 = float(input("Enter the second number: "))

            if operator == '+':
                result = num1 + num2
            elif operator == '-':
                result = num1 - num2
            elif operator == '*':
                result = num1 * num2
            elif operator == '/':
                if num2 == 0:
                    print("Error: Division by zero")
                    continue  # Skip to the next iteration
                else:
                    result = num1 / num2
            else:
                print("Invalid operator")
                continue  # Skip to the next iteration

            print("Result:", result)

        except ValueError:
            print("Invalid input. Please enter numbers and a valid operator.")

        choice = input("Do you want to perform another calculation? (y/n): ")
        if choice.lower() != 'y':
            break

calculator()
