/**
 * This exercise focuses on the intersection of two topics: infinite while loops and appending new elements to a list.
 *
 * Write a function that takes in the name of an actor/actress and a list of movies. The function should repeatedly prompt the user to enter a movie title and append it to the given list until the user enters "q" to quit. The function should return the updated list of movies.
 *
 * @param actor The name of the actor/actress.
 * @param movies A list of movies.
 * @return The updated list of movies.
 */
fun appendElements(actor: String, movies: MutableList<String>): List<String> {

    println("Welcome to the movie database of $actor!")
    println("Enter a movie title to add it to the database, or enter 'q' to quit.")

    while (true) {
        print("Enter a movie title: ")
        val movie = readLine() ?: ""

        if (movie.toLowerCase() == "q") {
            break
        }

        movies.add(movie)
    }

    return movies
}
/**
 * This exercise focuses on the intersection of two topics: infinite while loops and appending new elements to a list.
 *
 * Write a function that takes in the name of an actor/actress and a list of movies. The function should repeatedly prompt the user to enter a movie title and append it to the given list until the user enters "q" to quit. The function should return the updated list of movies.
 *
 * @param actor The name of the actor/actress.
 * @param movies A list of movies.
 * @return The updated list of movies.
 */
fun appendElements(actor: String, movies: MutableList<String>): List<String> {
/**
 * This exercise focuses on the intersection of two topics: infinite while loops and appending new elements to a list.
 *
 * Write a function that takes in the name of an actor/actress and a list of movies. The function should repeatedly prompt the user to enter a movie title and append it to the given list until the user enters "q" to quit. The function should return the updated list of movies.
 *
 * @param actor The name of the actor/actress.
 * @param movies A list of movies.
 * @return The updated list of movies.
 */
fun appendElements(actor: String, movies: MutableList<String>): List<String> {

    println("Welcome to the movie database of $actor!")
    println("Enter a movie title to add it to the database, or enter 'q' to quit.")

    while (true) {
        print("Enter a movie title: ")
        val movie = readLine() ?: ""

        if (movie.toLowerCase() == "q") {
            break
        }

        movies.add(movie)
    }

    return movies
}