/**
 * This function takes a list of animals and two indices as input,
 * and returns a list containing the species of animals between the given indices.
 *
 * @param animals A list of animals.
 * @param indexStart The index indicating the start position of the slicing.
 * @param indexEnd The index indicating the end position of the slicing.
 * @return A list of animal species between the given indices.
 */
fun findAnimalSpecies(animals: List<Map<String, String>>, indexStart: Int, indexEnd: Int): List<String> {

    val animalSpecies = mutableListOf<String>()

    // Iterate over each animal in the sliced portion of the list
    for (i in indexStart until indexEnd) {
        val animal = animals[i]

        // Extract the species from the animal
        val species = animal["species"]

        // Append the species to the animalSpecies list
        species?.let { animalSpecies.add(it) }
    }

    return animalSpecies
}
/**
 * This function takes a list of animals and two indices as input,
 * and returns a list containing the species of animals between the given indices.
 *
 * @param animals A list of animals.
 * @param indexStart The index indicating the start position of the slicing.
 * @param indexEnd The index indicating the end position of the slicing.
 * @return A list of animal species between the given indices.
 */
fun findAnimalSpecies(animals: List<Map<String, String>>, indexStart: Int, indexEnd: Int): List<String> {
/**
 * This function takes a list of animals and two indices as input,
 * and returns a list containing the species of animals between the given indices.
 *
 * @param animals A list of animals.
 * @param indexStart The index indicating the start position of the slicing.
 * @param indexEnd The index indicating the end position of the slicing.
 * @return A list of animal species between the given indices.
 */
fun findAnimalSpecies(animals: List<Map<String, String>>, indexStart: Int, indexEnd: Int): List<String> {

    val animalSpecies = mutableListOf<String>()

    // Iterate over each animal in the sliced portion of the list
    for (i in indexStart until indexEnd) {
        val animal = animals[i]

        // Extract the species from the animal
        val species = animal["species"]

        // Append the species to the animalSpecies list
        species?.let { animalSpecies.add(it) }
    }

    return animalSpecies
}