/**
 * Write a function that takes two lists as input and returns the common elements between them using looping structures and slicing tuples.
 *
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A tuple containing the common elements between list1 and list2
 *
 * Example:
 * Input:
 * list1 = [1, 2, 3, 4, 5, 6]
 * list2 = [4, 5, 6, 7, 8, 9]
 *
 * Output:
 * common_elements = (4, 5, 6)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

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

    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Append the element to commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Write a function that takes two lists as input and returns the common elements between them using looping structures and slicing tuples.
 *
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A tuple containing the common elements between list1 and list2
 *
 * Example:
 * Input:
 * list1 = [1, 2, 3, 4, 5, 6]
 * list2 = [4, 5, 6, 7, 8, 9]
 *
 * Output:
 * common_elements = (4, 5, 6)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Write a function that takes two lists as input and returns the common elements between them using looping structures and slicing tuples.
 *
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A tuple containing the common elements between list1 and list2
 *
 * Example:
 * Input:
 * list1 = [1, 2, 3, 4, 5, 6]
 * list2 = [4, 5, 6, 7, 8, 9]
 *
 * Output:
 * common_elements = (4, 5, 6)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

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

    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Append the element to commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}