/**
 * This function takes two lists of animals observed by two veterinarians.
 * Your task is to find the common animals observed by both veterinarians and return a list containing them.
 * If there are no common animals, return an empty list.
 */
fun findCommonAnimals(animals1: List<String>, animals2: List<String>): List<String> {

    val commonAnimals = mutableListOf<String>()

    // Append new animals from animals1 to commonAnimals if they are also observed by animals2
    for (animal in animals1) {
        if (animal !in commonAnimals && animal in animals2) {
            commonAnimals.add(animal)
        }
    }

    // Append new animals from animals2 to commonAnimals if they are also observed by animals1
    for (animal in animals2) {
        if (animal !in commonAnimals && animal in animals1) {
            commonAnimals.add(animal)
        }
    }

    return commonAnimals
}
/**
 * This function takes two lists of animals observed by two veterinarians.
 * Your task is to find the common animals observed by both veterinarians and return a list containing them.
 * If there are no common animals, return an empty list.
 */
fun findCommonAnimals(animals1: List<String>, animals2: List<String>): List<String> {
/**
 * This function takes two lists of animals observed by two veterinarians.
 * Your task is to find the common animals observed by both veterinarians and return a list containing them.
 * If there are no common animals, return an empty list.
 */
fun findCommonAnimals(animals1: List<String>, animals2: List<String>): List<String> {

    val commonAnimals = mutableListOf<String>()

    // Append new animals from animals1 to commonAnimals if they are also observed by animals2
    for (animal in animals1) {
        if (animal !in commonAnimals && animal in animals2) {
            commonAnimals.add(animal)
        }
    }

    // Append new animals from animals2 to commonAnimals if they are also observed by animals1
    for (animal in animals2) {
        if (animal !in commonAnimals && animal in animals1) {
            commonAnimals.add(animal)
        }
    }

    return commonAnimals
}