/**
 * This function replaces a specific animal in a list of animals with a new animal.
 *
 * @param animalList A list of animal names.
 * @param oldAnimal The name of the animal to replace.
 * @param newAnimal The name of the new animal.
 * @return A new list of animals with the specified animal replaced.
 */
fun replaceAnimal(animalList: List<String>, oldAnimal: String, newAnimal: String): List<String> {

    val newList = animalList.toMutableList()  // Copy the original list to avoid modifying it directly
    for (i in newList.indices) {
        if (newList[i] == oldAnimal) {
            newList[i] = newAnimal  // Replace the old animal with the new animal
        }
    }
    return newList
}
/**
 * This function replaces a specific animal in a list of animals with a new animal.
 *
 * @param animalList A list of animal names.
 * @param oldAnimal The name of the animal to replace.
 * @param newAnimal The name of the new animal.
 * @return A new list of animals with the specified animal replaced.
 */
fun replaceAnimal(animalList: List<String>, oldAnimal: String, newAnimal: String): List<String> {
/**
 * This function replaces a specific animal in a list of animals with a new animal.
 *
 * @param animalList A list of animal names.
 * @param oldAnimal The name of the animal to replace.
 * @param newAnimal The name of the new animal.
 * @return A new list of animals with the specified animal replaced.
 */
fun replaceAnimal(animalList: List<String>, oldAnimal: String, newAnimal: String): List<String> {

    val newList = animalList.toMutableList()  // Copy the original list to avoid modifying it directly
    for (i in newList.indices) {
        if (newList[i] == oldAnimal) {
            newList[i] = newAnimal  // Replace the old animal with the new animal
        }
    }
    return newList
}