/**
 * This exercise tests your ability to access elements in a list and perform simple assignment operations.
 *
 * Given two lists, list1 and list2, write a function that finds and returns a new list containing the elements that are common to both list1 and list2. The order of elements in the new list should be the same as they appear in list1.
 *
 * @param list1 A list of elements.
 * @param list2 Another list of elements.
 * @return A list of common elements between list1 and list2, in the order they appear in list1.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val list3 = mutableListOf<Any>()  // Initialize an empty list to store common elements

    for (element in list1) {
        if (element in list2) {  // Check if the element is present in list2
            list3.add(element)  // Append the common element to list3
        }
    }

    return list3
}
/**
 * This exercise tests your ability to access elements in a list and perform simple assignment operations.
 *
 * Given two lists, list1 and list2, write a function that finds and returns a new list containing the elements that are common to both list1 and list2. The order of elements in the new list should be the same as they appear in list1.
 *
 * @param list1 A list of elements.
 * @param list2 Another list of elements.
 * @return A list of common elements between list1 and list2, in the order they appear in list1.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise tests your ability to access elements in a list and perform simple assignment operations.
 *
 * Given two lists, list1 and list2, write a function that finds and returns a new list containing the elements that are common to both list1 and list2. The order of elements in the new list should be the same as they appear in list1.
 *
 * @param list1 A list of elements.
 * @param list2 Another list of elements.
 * @return A list of common elements between list1 and list2, in the order they appear in list1.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val list3 = mutableListOf<Any>()  // Initialize an empty list to store common elements

    for (element in list1) {
        if (element in list2) {  // Check if the element is present in list2
            list3.add(element)  // Append the common element to list3
        }
    }

    return list3
}