/**
 * This function counts the number of occurrences of a given species in a list of species, 
 * and stops counting when the breakSpecies is encountered.
 *
 * @param speciesList A list of species.
 * @param breakSpecies The species at which counting should stop.
 * @return The number of occurrences of the given species before encountering the breakSpecies.
 *
 * Example:
 * countSpecies(listOf("cat", "cat", "dog", "cat", "bird", "cat", "bear", "cat"), "bird")
 * Output: 3
 */
fun countSpecies(speciesList: List<String>, breakSpecies: String): Int {

    var count = 0
    for (species in speciesList) {
        if (species == breakSpecies) {
            break
        }
        if (species == "cat") {
            count++
        }
    }
    return count
}
/**
 * This function counts the number of occurrences of a given species in a list of species, 
 * and stops counting when the breakSpecies is encountered.
 *
 * @param speciesList A list of species.
 * @param breakSpecies The species at which counting should stop.
 * @return The number of occurrences of the given species before encountering the breakSpecies.
 *
 * Example:
 * countSpecies(listOf("cat", "cat", "dog", "cat", "bird", "cat", "bear", "cat"), "bird")
 * Output: 3
 */
fun countSpecies(speciesList: List<String>, breakSpecies: String): Int {
/**
 * This function counts the number of occurrences of a given species in a list of species, 
 * and stops counting when the breakSpecies is encountered.
 *
 * @param speciesList A list of species.
 * @param breakSpecies The species at which counting should stop.
 * @return The number of occurrences of the given species before encountering the breakSpecies.
 *
 * Example:
 * countSpecies(listOf("cat", "cat", "dog", "cat", "bird", "cat", "bear", "cat"), "bird")
 * Output: 3
 */
fun countSpecies(speciesList: List<String>, breakSpecies: String): Int {

    var count = 0
    for (species in speciesList) {
        if (species == breakSpecies) {
            break
        }
        if (species == "cat") {
            count++
        }
    }
    return count
}