/**
 * Given a list of species and a target species, this function finds the index of the target species in the list.
 *
 * @param speciesList A list of species names.
 * @param targetSpecies The name of the target species to find.
 * @return The index of the target species in the list.
 * @throws IllegalArgumentException If the target species is not found in the list.
 *
 * Example:
 * findSpecies(listOf("dog", "cat", "lion", "elephant"), "cat") -> 1
 */
fun findSpecies(speciesList: List<String>, targetSpecies: String): Int {

    for ((index, species) in speciesList.withIndex()) {
        if (species == targetSpecies) {
            return index
        }
    }
    
    // If target species is not found
    throw IllegalArgumentException("Target species not found in the list.")
}
/**
 * Given a list of species and a target species, this function finds the index of the target species in the list.
 *
 * @param speciesList A list of species names.
 * @param targetSpecies The name of the target species to find.
 * @return The index of the target species in the list.
 * @throws IllegalArgumentException If the target species is not found in the list.
 *
 * Example:
 * findSpecies(listOf("dog", "cat", "lion", "elephant"), "cat") -> 1
 */
fun findSpecies(speciesList: List<String>, targetSpecies: String): Int {
/**
 * Given a list of species and a target species, this function finds the index of the target species in the list.
 *
 * @param speciesList A list of species names.
 * @param targetSpecies The name of the target species to find.
 * @return The index of the target species in the list.
 * @throws IllegalArgumentException If the target species is not found in the list.
 *
 * Example:
 * findSpecies(listOf("dog", "cat", "lion", "elephant"), "cat") -> 1
 */
fun findSpecies(speciesList: List<String>, targetSpecies: String): Int {

    for ((index, species) in speciesList.withIndex()) {
        if (species == targetSpecies) {
            return index
        }
    }
    
    // If target species is not found
    throw IllegalArgumentException("Target species not found in the list.")
}