/**
 * This function takes two lists as input and appends the common elements from both lists into a new list.
 *
 * @param list1 A list containing integers
 * @param list2 A list containing integers
 * @return A list containing common elements
 *
 * Example:
 * appendCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun appendCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (elem in list1) {
        if (elem in list2) {
            commonElements.add(elem)
        }
    }
    return commonElements
}
/**
 * This function takes two lists as input and appends the common elements from both lists into a new list.
 *
 * @param list1 A list containing integers
 * @param list2 A list containing integers
 * @return A list containing common elements
 *
 * Example:
 * appendCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun appendCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This function takes two lists as input and appends the common elements from both lists into a new list.
 *
 * @param list1 A list containing integers
 * @param list2 A list containing integers
 * @return A list containing common elements
 *
 * Example:
 * appendCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun appendCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (elem in list1) {
        if (elem in list2) {
            commonElements.add(elem)
        }
    }
    return commonElements
}