/**
 * Given a list of numbers and a target number, this function appends the numbers to a new list based on a condition.
 * If the number is even, it is appended to the list. If the number is odd, it is skipped.
 * Finally, after appending the even numbers, an else statement is included to append the target number if it is even,
 * and a different element if it is odd.
 *
 * @param numbers A list of numbers.
 * @param target The target number.
 * @return A list of even numbers from the input list, along with the target number or a different element.
 */
fun appendAndElse(numbers: List<Int>, target: Int): List<Int> {

    val newList = mutableListOf<Int>()
    
    for (num in numbers) {
        if (num % 2 == 0) {
            newList.add(num)
        }
    }
    
    // Append the target number if it is even, else append a different element
    if (target % 2 == 0) {
        // Append the target number to the list
        newList.add(target)
    } else {
        // Append a different element to the list
        newList.add(0)
    }
    
    return newList
}
/**
 * Given a list of numbers and a target number, this function appends the numbers to a new list based on a condition.
 * If the number is even, it is appended to the list. If the number is odd, it is skipped.
 * Finally, after appending the even numbers, an else statement is included to append the target number if it is even,
 * and a different element if it is odd.
 *
 * @param numbers A list of numbers.
 * @param target The target number.
 * @return A list of even numbers from the input list, along with the target number or a different element.
 */
fun appendAndElse(numbers: List<Int>, target: Int): List<Int> {
/**
 * Given a list of numbers and a target number, this function appends the numbers to a new list based on a condition.
 * If the number is even, it is appended to the list. If the number is odd, it is skipped.
 * Finally, after appending the even numbers, an else statement is included to append the target number if it is even,
 * and a different element if it is odd.
 *
 * @param numbers A list of numbers.
 * @param target The target number.
 * @return A list of even numbers from the input list, along with the target number or a different element.
 */
fun appendAndElse(numbers: List<Int>, target: Int): List<Int> {

    val newList = mutableListOf<Int>()
    
    for (num in numbers) {
        if (num % 2 == 0) {
            newList.add(num)
        }
    }
    
    // Append the target number if it is even, else append a different element
    if (target % 2 == 0) {
        // Append the target number to the list
        newList.add(target)
    } else {
        // Append a different element to the list
        newList.add(0)
    }
    
    return newList
}