def calculate(num1, operator, num2):
    if operator == '+':
        return num1 + num2
    elif operator == '-':
        return num1 - num2
    elif operator == '*':
        return num1 * num2
    elif operator == '/':
        if num2 == 0:
            return "Error: Division by zero!"
        else:
            return num1 / num2
    else:
        return "Error: Invalid operator!"

def main():
    while True:
        try:
            num1 = float(input("Enter the first number: "))
            operator = input("Enter the operator (+, -, *, /): ")
            num2 = float(input("Enter the second number: "))

            result = calculate(num1, operator, num2)
            print("Result:", result)
        except ValueError:
            print("Error: Please enter valid numbers!")
        except Exception as e:
            print("An error occurred:", e)

        choice = input("Do you want to perform another calculation? (yes/no): ").lower()
        if choice != 'yes':
            break

if __name__ == "__main__":
    main()
