/**
 * You are given a list of elements and a new element. Your task is to modify the given list in the following way:
 * - If the new element is already present in the list, remove all occurrences of the element.
 * - Otherwise, append the new element to the list.
 *
 * @param elementList A list of elements.
 * @param newElement The new element to modify the list with.
 * @return The modified list.
 */
fun modifyElementList(elementList: MutableList<Any>, newElement: Any): List<Any> {

    if (newElement in elementList) {
        // Remove all occurrences of the new element from the list
        while (newElement in elementList) {
            elementList.remove(newElement)
        }
    } else {
        // Append the new element to the list
        elementList.add(newElement)
    }

    return elementList
}
/**
 * You are given a list of elements and a new element. Your task is to modify the given list in the following way:
 * - If the new element is already present in the list, remove all occurrences of the element.
 * - Otherwise, append the new element to the list.
 *
 * @param elementList A list of elements.
 * @param newElement The new element to modify the list with.
 * @return The modified list.
 */
fun modifyElementList(elementList: MutableList<Any>, newElement: Any): List<Any> {
/**
 * You are given a list of elements and a new element. Your task is to modify the given list in the following way:
 * - If the new element is already present in the list, remove all occurrences of the element.
 * - Otherwise, append the new element to the list.
 *
 * @param elementList A list of elements.
 * @param newElement The new element to modify the list with.
 * @return The modified list.
 */
fun modifyElementList(elementList: MutableList<Any>, newElement: Any): List<Any> {

    if (newElement in elementList) {
        // Remove all occurrences of the new element from the list
        while (newElement in elementList) {
            elementList.remove(newElement)
        }
    } else {
        // Append the new element to the list
        elementList.add(newElement)
    }

    return elementList
}