/**
 * This exercise aims to find the common elements between two lists using the 'and' operator.
 *
 * Complete the function 'findCommonElements' to return a new list that contains only the elements present in both input lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Iterate over each element in list1
    for (element in list1) {
        // Use 'and' operator to check if the element is present in both list1 and list2
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    // Return the list of common elements
    return commonElements
}
/**
 * This exercise aims to find the common elements between two lists using the 'and' operator.
 *
 * Complete the function 'findCommonElements' to return a new list that contains only the elements present in both input lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise aims to find the common elements between two lists using the 'and' operator.
 *
 * Complete the function 'findCommonElements' to return a new list that contains only the elements present in both input lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Iterate over each element in list1
    for (element in list1) {
        // Use 'and' operator to check if the element is present in both list1 and list2
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    // Return the list of common elements
    return commonElements
}