/**
 * This function removes unwanted animals from the list of animals on a farm.
 *
 * @param animals The list of animals on the farm.
 * @param unwanted The list of unwanted animals.
 * @return The updated list of animals on the farm after removing the unwanted ones.
 */
fun removeUnwantedAnimals(animals: MutableList<String>, unwanted: List<String>): List<String> {

    // Check if each unwanted animal is present in the list
    for (animal in unwanted) {
        if (animal !in animals) {
            // If an unwanted animal is not found, raise an Exception
            throw IllegalArgumentException("$animal does not exist on the farm.")
        }
    }

    // Remove each unwanted animal from the list
    for (animal in unwanted) {
        animals.remove(animal)
    }

    return animals
}
/**
 * This function removes unwanted animals from the list of animals on a farm.
 *
 * @param animals The list of animals on the farm.
 * @param unwanted The list of unwanted animals.
 * @return The updated list of animals on the farm after removing the unwanted ones.
 */
fun removeUnwantedAnimals(animals: MutableList<String>, unwanted: List<String>): List<String> {
/**
 * This function removes unwanted animals from the list of animals on a farm.
 *
 * @param animals The list of animals on the farm.
 * @param unwanted The list of unwanted animals.
 * @return The updated list of animals on the farm after removing the unwanted ones.
 */
fun removeUnwantedAnimals(animals: MutableList<String>, unwanted: List<String>): List<String> {

    // Check if each unwanted animal is present in the list
    for (animal in unwanted) {
        if (animal !in animals) {
            // If an unwanted animal is not found, raise an Exception
            throw IllegalArgumentException("$animal does not exist on the farm.")
        }
    }

    // Remove each unwanted animal from the list
    for (animal in unwanted) {
        animals.remove(animal)
    }

    return animals
}