/**
 * Given a list of animals, modify the name of the animal at the given index with a new name.
 *
 * @param animals A list of animal names.
 * @param index The index of the animal to be modified.
 * @param newName The new name to assign to the animal.
 * @return The modified list of animal names.
 */
fun changeAnimalName(animals: MutableList<String>, index: Int, newName: String): List<String> {

    if (animals.size > index && index >= 0) {  // Check if the index is within the range of the animals list
        animals[index] = newName  // Modifying the name of the animal at the given index
    } else {
        println("Invalid index!")  // Print an error message if the index is out of range
    }

    return animals
}
/**
 * Given a list of animals, modify the name of the animal at the given index with a new name.
 *
 * @param animals A list of animal names.
 * @param index The index of the animal to be modified.
 * @param newName The new name to assign to the animal.
 * @return The modified list of animal names.
 */
fun changeAnimalName(animals: MutableList<String>, index: Int, newName: String): List<String> {
/**
 * Given a list of animals, modify the name of the animal at the given index with a new name.
 *
 * @param animals A list of animal names.
 * @param index The index of the animal to be modified.
 * @param newName The new name to assign to the animal.
 * @return The modified list of animal names.
 */
fun changeAnimalName(animals: MutableList<String>, index: Int, newName: String): List<String> {

    if (animals.size > index && index >= 0) {  // Check if the index is within the range of the animals list
        animals[index] = newName  // Modifying the name of the animal at the given index
    } else {
        println("Invalid index!")  // Print an error message if the index is out of range
    }

    return animals
}