/**
 * Zoologist needs to count the number of animals in a particular habitat.
 *
 * Write a function that takes in a list of animals and a habitat name and returns the total count of animals
 * belonging to that habitat. The function should utilize a combination of for loops and while loops.
 *
 * @param animals A list of strings representing the names of animals.
 * @param habitat A string representing the name of the habitat to count animals in.
 * @return An integer representing the total count of animals in the specified habitat.
 */
fun countAnimals(animals: List<String>, habitat: String): Int {

    var count = 0
    var index = 0

    while (index < animals.size) {
        for (animal in animals) {
            if (animal == habitat) {
                count++
            }
        }
        index++
    }

    return count
}
/**
 * Zoologist needs to count the number of animals in a particular habitat.
 *
 * Write a function that takes in a list of animals and a habitat name and returns the total count of animals
 * belonging to that habitat. The function should utilize a combination of for loops and while loops.
 *
 * @param animals A list of strings representing the names of animals.
 * @param habitat A string representing the name of the habitat to count animals in.
 * @return An integer representing the total count of animals in the specified habitat.
 */
fun countAnimals(animals: List<String>, habitat: String): Int {
/**
 * Zoologist needs to count the number of animals in a particular habitat.
 *
 * Write a function that takes in a list of animals and a habitat name and returns the total count of animals
 * belonging to that habitat. The function should utilize a combination of for loops and while loops.
 *
 * @param animals A list of strings representing the names of animals.
 * @param habitat A string representing the name of the habitat to count animals in.
 * @return An integer representing the total count of animals in the specified habitat.
 */
fun countAnimals(animals: List<String>, habitat: String): Int {

    var count = 0
    var index = 0

    while (index < animals.size) {
        for (animal in animals) {
            if (animal == habitat) {
                count++
            }
        }
        index++
    }

    return count
}