/**
 * The function takes a list 'farm' and an 'animal' string as input.
 * It checks if the 'animal' is already present in the 'farm' and, if not, adds it to the 'farm.
 * The modified 'farm' list is returned as output.
 */
fun addAnimal(farm: MutableList<String>, animal: String): MutableList<String> {

    for (existingAnimal in farm) {
        // Check if the 'animal' already exists in the 'farm'
        if (existingAnimal == animal) {
            println("$animal already exists on the farm.")
            return farm
        }
    }

    // If the 'animal' is not present, add it to the 'farm'
    farm.add(animal)
    println("$animal added to the farm.")
    return farm
}
/**
 * The function takes a list 'farm' and an 'animal' string as input.
 * It checks if the 'animal' is already present in the 'farm' and, if not, adds it to the 'farm.
 * The modified 'farm' list is returned as output.
 */
fun addAnimal(farm: MutableList<String>, animal: String): MutableList<String> {
/**
 * The function takes a list 'farm' and an 'animal' string as input.
 * It checks if the 'animal' is already present in the 'farm' and, if not, adds it to the 'farm.
 * The modified 'farm' list is returned as output.
 */
fun addAnimal(farm: MutableList<String>, animal: String): MutableList<String> {

    for (existingAnimal in farm) {
        // Check if the 'animal' already exists in the 'farm'
        if (existingAnimal == animal) {
            println("$animal already exists on the farm.")
            return farm
        }
    }

    // If the 'animal' is not present, add it to the 'farm'
    farm.add(animal)
    println("$animal added to the farm.")
    return farm
}