/**
 * Given a list, append a new element at a specific index
 */
fun indexAndAppend(list1: MutableList<Any>, element: Any, index: Int): Any {

    // Check if the provided index is within the range of the list
    if (index >= list1.size || index < 0) {
        return "Invalid index"
    }

    // Insert the new element at the specified index
    list1.add(index, element)

    return list1
}
/**
 * Given a list, append a new element at a specific index
 */
fun indexAndAppend(list1: MutableList<Any>, element: Any, index: Int): Any {
/**
 * Given a list, append a new element at a specific index
 */
fun indexAndAppend(list1: MutableList<Any>, element: Any, index: Int): Any {

    // Check if the provided index is within the range of the list
    if (index >= list1.size || index < 0) {
        return "Invalid index"
    }

    // Insert the new element at the specified index
    list1.add(index, element)

    return list1
}