/**
 * This function takes two lists as input and returns the common elements between them.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    try {
        // Check if both inputs are lists
        if (list1 !is List<*> || list2 !is List<*>) {
            throw IllegalArgumentException("Both inputs must be lists.")
        }

        val commonElements = mutableListOf<Any>()
        for (element1 in list1) {
            try {
                // Check if element1 is in list2
                if (element1 in list2) {
                    commonElements.add(element1)
                }
            } catch (e: Exception) {
                continue
            }
        }

        return commonElements

    } catch (e: Exception) {
        return listOf(e.toString())
    }
}
/**
 * This function takes two lists as input and returns the common elements between them.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This function takes two lists as input and returns the common elements between them.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    try {
        // Check if both inputs are lists
        if (list1 !is List<*> || list2 !is List<*>) {
            throw IllegalArgumentException("Both inputs must be lists.")
        }

        val commonElements = mutableListOf<Any>()
        for (element1 in list1) {
            try {
                // Check if element1 is in list2
                if (element1 in list2) {
                    commonElements.add(element1)
                }
            } catch (e: Exception) {
                continue
            }
        }

        return commonElements

    } catch (e: Exception) {
        return listOf(e.toString())
    }
}