/**
 * This exercise aims to test the social worker's understanding of list methods and indexing tuples.
 * The task is to write a function that takes in two lists and returns a new list containing only the common elements
 * found in both lists, preserving the order in which they appear in the first list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements found in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over the elements in list1
    for (element in list1) {
        // Check if the element is present in both list1 and list2
        if (element in list2) {
            // Add the common element to the new list
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * This exercise aims to test the social worker's understanding of list methods and indexing tuples.
 * The task is to write a function that takes in two lists and returns a new list containing only the common elements
 * found in both lists, preserving the order in which they appear in the first list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements found in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise aims to test the social worker's understanding of list methods and indexing tuples.
 * The task is to write a function that takes in two lists and returns a new list containing only the common elements
 * found in both lists, preserving the order in which they appear in the first list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements found in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over the elements in list1
    for (element in list1) {
        // Check if the element is present in both list1 and list2
        if (element in list2) {
            // Add the common element to the new list
            commonElements.add(element)
        }
    }

    return commonElements
}