/**
 * This exercise aims to test your understanding of list slicing and short-circuiting.
 * You need to complete the code below to find the common elements between two lists.
 *
 * @param list1 The first list containing elements (can be of any type)
 * @param list2 The second list containing elements (can be of any type)
 * @return A list containing the elements common to both list1 and list2
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over each element in list1
    for (element in list1) {
        // Use short-circuiting and list slicing to check if the element is present in list2
        if (element in list2) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * This exercise aims to test your understanding of list slicing and short-circuiting.
 * You need to complete the code below to find the common elements between two lists.
 *
 * @param list1 The first list containing elements (can be of any type)
 * @param list2 The second list containing elements (can be of any type)
 * @return A list containing the elements common to both list1 and list2
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise aims to test your understanding of list slicing and short-circuiting.
 * You need to complete the code below to find the common elements between two lists.
 *
 * @param list1 The first list containing elements (can be of any type)
 * @param list2 The second list containing elements (can be of any type)
 * @return A list containing the elements common to both list1 and list2
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over each element in list1
    for (element in list1) {
        // Use short-circuiting and list slicing to check if the element is present in list2
        if (element in list2) {
            commonElements.add(element)
        }
    }

    return commonElements
}