def calculate(num1, num2, operator):
  
  if operator == "+":
    return num1 + num2
  elif operator == "-":
    return num1 - num2
  elif operator == "*":
    return num1 * num2
  elif operator == "/":
    if num2 == 0:
      raise ValueError("Cannot be divided by zero")
    else:
      return num1 / num2
  else:
    raise ValueError("Invalid operator")

def main():
  
  while True:
    try:
      num1 = float(input("Enter the first number: "))
      num2 = float(input("Enter the second number: "))
      operator = input("Enter the operator (+, -, *, /): ")

      Result = calculate(num1, num2, operator)

      print(Result)

    except ValueError as e:
      print("Error: {e}")

    continue_prompt = input("Do you want to perform another operation? (yes/no): ")
    if continue_prompt.lower() not in ("yes", "no"):
      break

if __name__ == "__main__":
  main()
