/**
 * This function takes two lists as input and returns a list containing the common elements.
 *
 * Exercise:
 * Given two lists, list1 and list2, write a function to find the common elements present in both the lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements present in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Loop through each element in list1
    for (element1 in list1) {
        // Loop through each element in list2
        for (element2 in list2) {
            // Check if the current element from list1 is equal to the current element from list2
            if (element1 == element2) {
                // Check if the current element is not already in the commonElements list
                if (!commonElements.contains(element1)) {
                    commonElements.add(element1)
                }
            }
        }
    }

    return commonElements
}
/**
 * This function takes two lists as input and returns a list containing the common elements.
 *
 * Exercise:
 * Given two lists, list1 and list2, write a function to find the common elements present in both the lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements present in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This function takes two lists as input and returns a list containing the common elements.
 *
 * Exercise:
 * Given two lists, list1 and list2, write a function to find the common elements present in both the lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements present in both list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Loop through each element in list1
    for (element1 in list1) {
        // Loop through each element in list2
        for (element2 in list2) {
            // Check if the current element from list1 is equal to the current element from list2
            if (element1 == element2) {
                // Check if the current element is not already in the commonElements list
                if (!commonElements.contains(element1)) {
                    commonElements.add(element1)
                }
            }
        }
    }

    return commonElements
}