/**
 * Given a list of items, replace an item at the specified index with a new value.
 *
 * @param items The original list of items.
 * @param index The index at which the item needs to be replaced.
 * @param replacement The new value to replace the item at the specified index.
 * @return The modified list with the item replaced at the specified index.
 *
 * Examples:
 * replaceItemsWithIndex(listOf("Chair", "Table", "Lamp"), 1, "Sofa")
 * output: ['Chair', 'Sofa', 'Lamp']
 */
fun replaceItemsWithIndex(items: MutableList<String>, index: Int, replacement: String): List<String> {

    // Check if the index is within the range of the list
    if (index in items.indices) {
        items[index] = replacement  // Replace the item with the new value
    }
    return items
}
/**
 * Given a list of items, replace an item at the specified index with a new value.
 *
 * @param items The original list of items.
 * @param index The index at which the item needs to be replaced.
 * @param replacement The new value to replace the item at the specified index.
 * @return The modified list with the item replaced at the specified index.
 *
 * Examples:
 * replaceItemsWithIndex(listOf("Chair", "Table", "Lamp"), 1, "Sofa")
 * output: ['Chair', 'Sofa', 'Lamp']
 */
fun replaceItemsWithIndex(items: MutableList<String>, index: Int, replacement: String): List<String> {
/**
 * Given a list of items, replace an item at the specified index with a new value.
 *
 * @param items The original list of items.
 * @param index The index at which the item needs to be replaced.
 * @param replacement The new value to replace the item at the specified index.
 * @return The modified list with the item replaced at the specified index.
 *
 * Examples:
 * replaceItemsWithIndex(listOf("Chair", "Table", "Lamp"), 1, "Sofa")
 * output: ['Chair', 'Sofa', 'Lamp']
 */
fun replaceItemsWithIndex(items: MutableList<String>, index: Int, replacement: String): List<String> {

    // Check if the index is within the range of the list
    if (index in items.indices) {
        items[index] = replacement  // Replace the item with the new value
    }
    return items
}