/**
 * Given a list of animals, replace all occurrences of the old animal with the new animal.
 *
 * @param animalList A list of animals.
 * @param oldAnimal The name of the animal to be replaced.
 * @param newAnimal The name of the replacement animal.
 * @return The modified list with all occurrences of the old animal replaced with the new animal.
 *
 * Example:
 * animalList = listOf("lion", "tiger", "elephant", "lion")
 * replaceAnimal(animalList, "lion", "reindeer") // Output: ["reindeer", "tiger", "elephant", "reindeer"]
 */
fun replaceAnimal(animalList: MutableList<String>, oldAnimal: String, newAnimal: String): List<String> {

    for (i in animalList.indices) {
        if (animalList[i] == oldAnimal) {
            animalList[i] = newAnimal
        }
    }
    return animalList
}
/**
 * Given a list of animals, replace all occurrences of the old animal with the new animal.
 *
 * @param animalList A list of animals.
 * @param oldAnimal The name of the animal to be replaced.
 * @param newAnimal The name of the replacement animal.
 * @return The modified list with all occurrences of the old animal replaced with the new animal.
 *
 * Example:
 * animalList = listOf("lion", "tiger", "elephant", "lion")
 * replaceAnimal(animalList, "lion", "reindeer") // Output: ["reindeer", "tiger", "elephant", "reindeer"]
 */
fun replaceAnimal(animalList: MutableList<String>, oldAnimal: String, newAnimal: String): List<String> {
/**
 * Given a list of animals, replace all occurrences of the old animal with the new animal.
 *
 * @param animalList A list of animals.
 * @param oldAnimal The name of the animal to be replaced.
 * @param newAnimal The name of the replacement animal.
 * @return The modified list with all occurrences of the old animal replaced with the new animal.
 *
 * Example:
 * animalList = listOf("lion", "tiger", "elephant", "lion")
 * replaceAnimal(animalList, "lion", "reindeer") // Output: ["reindeer", "tiger", "elephant", "reindeer"]
 */
fun replaceAnimal(animalList: MutableList<String>, oldAnimal: String, newAnimal: String): List<String> {

    for (i in animalList.indices) {
        if (animalList[i] == oldAnimal) {
            animalList[i] = newAnimal
        }
    }
    return animalList
}