/**
 * Given two lists of animals, find the common animals between them using nested looping statements and the ternary operator.
 *
 * @param animalList1 the first list of animals
 * @param animalList2 the second list of animals
 * @return a list of common animals found in both lists
 */
fun findCommonAnimal(animalList1: List<String>, animalList2: List<String>): List<String> {

    val commonAnimals = mutableListOf<String>()

    // Loop through each animal in animalList1
    for (animal1 in animalList1) {
        // Loop through each animal in animalList2
        for (animal2 in animalList2) {
            // Check if the animal from animalList1 is equal to the animal from animalList2
            if (animal1 == animal2) {
                commonAnimals.add(animal1)
            }
        }
    }

    return commonAnimals
}

// Example usage
val listOfAnimals1 = listOf("lion", "tiger", "elephant", "giraffe", "zebra")
val listOfAnimals2 = listOf("elephant", "lion", "rhinoceros", "giraffe")
/**
 * Given two lists of animals, find the common animals between them using nested looping statements and the ternary operator.
 *
 * @param animalList1 the first list of animals
 * @param animalList2 the second list of animals
 * @return a list of common animals found in both lists
 */
fun findCommonAnimal(animalList1: List<String>, animalList2: List<String>): List<String> {
/**
 * Given two lists of animals, find the common animals between them using nested looping statements and the ternary operator.
 *
 * @param animalList1 the first list of animals
 * @param animalList2 the second list of animals
 * @return a list of common animals found in both lists
 */
fun findCommonAnimal(animalList1: List<String>, animalList2: List<String>): List<String> {

    val commonAnimals = mutableListOf<String>()

    // Loop through each animal in animalList1
    for (animal1 in animalList1) {
        // Loop through each animal in animalList2
        for (animal2 in animalList2) {
            // Check if the animal from animalList1 is equal to the animal from animalList2
            if (animal1 == animal2) {
                commonAnimals.add(animal1)
            }
        }
    }

    return commonAnimals
}

// Example usage
val listOfAnimals1 = listOf("lion", "tiger", "elephant", "giraffe", "zebra")
val listOfAnimals2 = listOf("elephant", "lion", "rhinoceros", "giraffe")