/**
 * You are a librarian and have been given a list of books in your library.
 * Your task is to replace all occurrences of a certain book with a new book using list methods and loops.
 *
 * @param bookList A list of books in the library
 * @param oldBook The book to be replaced
 * @param newBook The book to replace the oldBook with
 * @return The modified bookList with all instances of oldBook replaced with newBook
 */
fun replaceBooks(bookList: MutableList<String>, oldBook: String, newBook: String): MutableList<String> {

    for (i in bookList.indices) {
        if (bookList[i] == oldBook) {
            bookList[i] = newBook
        }
    }
    return bookList
}
/**
 * You are a librarian and have been given a list of books in your library.
 * Your task is to replace all occurrences of a certain book with a new book using list methods and loops.
 *
 * @param bookList A list of books in the library
 * @param oldBook The book to be replaced
 * @param newBook The book to replace the oldBook with
 * @return The modified bookList with all instances of oldBook replaced with newBook
 */
fun replaceBooks(bookList: MutableList<String>, oldBook: String, newBook: String): MutableList<String> {
/**
 * You are a librarian and have been given a list of books in your library.
 * Your task is to replace all occurrences of a certain book with a new book using list methods and loops.
 *
 * @param bookList A list of books in the library
 * @param oldBook The book to be replaced
 * @param newBook The book to replace the oldBook with
 * @return The modified bookList with all instances of oldBook replaced with newBook
 */
fun replaceBooks(bookList: MutableList<String>, oldBook: String, newBook: String): MutableList<String> {

    for (i in bookList.indices) {
        if (bookList[i] == oldBook) {
            bookList[i] = newBook
        }
    }
    return bookList
}