/**
 * A zoologist is trying to identify the common species between two sets of animals.
 * Complete the function below to find the intersection of two sets using a for loop.
 *
 * @param zooAnimals A list containing the names of animals in the zoo.
 * @param rainforestAnimals A set containing the names of animals in the rainforest.
 * @return A set of the common species found in both zooAnimals and rainforestAnimals.
 * If no common species are found, return an empty set.
 */
fun findCommonSpecies(zooAnimals: List<String>, rainforestAnimals: Set<String>): Set<String> {

    val commonSpecies = mutableSetOf<String>()

    // Loop through each animal in the zoo
    for (animal in zooAnimals) {
        // Check if the animal is also present in the rainforest
        if (animal in rainforestAnimals) {
            // Add the common species to the set
            commonSpecies.add(animal)
        }
    }

    return commonSpecies
}

// Example usage
val zooAnimals = listOf("lion", "elephant", "giraffe", "tiger", "penguin")
val rainforestAnimals = setOf("elephant", "parrot", "monkey", "giraffe")

val result = findCommonSpecies(zooAnimals, rainforestAnimals)
/**
 * A zoologist is trying to identify the common species between two sets of animals.
 * Complete the function below to find the intersection of two sets using a for loop.
 *
 * @param zooAnimals A list containing the names of animals in the zoo.
 * @param rainforestAnimals A set containing the names of animals in the rainforest.
 * @return A set of the common species found in both zooAnimals and rainforestAnimals.
 * If no common species are found, return an empty set.
 */
fun findCommonSpecies(zooAnimals: List<String>, rainforestAnimals: Set<String>): Set<String> {
/**
 * A zoologist is trying to identify the common species between two sets of animals.
 * Complete the function below to find the intersection of two sets using a for loop.
 *
 * @param zooAnimals A list containing the names of animals in the zoo.
 * @param rainforestAnimals A set containing the names of animals in the rainforest.
 * @return A set of the common species found in both zooAnimals and rainforestAnimals.
 * If no common species are found, return an empty set.
 */
fun findCommonSpecies(zooAnimals: List<String>, rainforestAnimals: Set<String>): Set<String> {

    val commonSpecies = mutableSetOf<String>()

    // Loop through each animal in the zoo
    for (animal in zooAnimals) {
        // Check if the animal is also present in the rainforest
        if (animal in rainforestAnimals) {
            // Add the common species to the set
            commonSpecies.add(animal)
        }
    }

    return commonSpecies
}

// Example usage
val zooAnimals = listOf("lion", "elephant", "giraffe", "tiger", "penguin")
val rainforestAnimals = setOf("elephant", "parrot", "monkey", "giraffe")

val result = findCommonSpecies(zooAnimals, rainforestAnimals)