/**
 * This function modifies a musician's attributes based on the given modification.
 *
 * @param musician A dictionary representing the musician and their attributes.
 * @param modification A string representing the desired modification to be made.
 * @return The modified musician dictionary.
 */
fun modifyMusician(musician: MutableMap<String, Any>, modification: String): MutableMap<String, Any> {

    when (modification) {
        "increase_age" -> musician["age"] = (musician["age"] as Int) + 1
        "add_instrument" -> {
            print("Enter the name of the instrument to add: ")
            val instrument = readLine()
            musician["instruments"] = (musician["instruments"] as MutableList<String>).apply { add(instrument.orEmpty()) }
        }
        "remove_instrument" -> {
            print("Enter the name of the instrument to remove: ")
            val instrument = readLine()
            if ((musician["instruments"] as MutableList<String>).contains(instrument)) {
                (musician["instruments"] as MutableList<String>).remove(instrument)
            } else {
                println("Instrument not found!")
            }
        }
        "change_genre" -> {
            print("Enter the new genre: ")
            val genre = readLine()
            musician["genre"] = genre.orEmpty()
        }
        "modify_name" -> {
            print("Enter the new name: ")
            val name = readLine()
            musician["name"] = name.orEmpty()
        }
        else -> println("Invalid modification!")
    }

    return musician
}

val musician = mutableMapOf(
    "name" to ""
)
/**
 * This function modifies a musician's attributes based on the given modification.
 *
 * @param musician A dictionary representing the musician and their attributes.
 * @param modification A string representing the desired modification to be made.
 * @return The modified musician dictionary.
 */
fun modifyMusician(musician: MutableMap<String, Any>, modification: String): MutableMap<String, Any> {
/**
 * This function modifies a musician's attributes based on the given modification.
 *
 * @param musician A dictionary representing the musician and their attributes.
 * @param modification A string representing the desired modification to be made.
 * @return The modified musician dictionary.
 */
fun modifyMusician(musician: MutableMap<String, Any>, modification: String): MutableMap<String, Any> {

    when (modification) {
        "increase_age" -> musician["age"] = (musician["age"] as Int) + 1
        "add_instrument" -> {
            print("Enter the name of the instrument to add: ")
            val instrument = readLine()
            musician["instruments"] = (musician["instruments"] as MutableList<String>).apply { add(instrument.orEmpty()) }
        }
        "remove_instrument" -> {
            print("Enter the name of the instrument to remove: ")
            val instrument = readLine()
            if ((musician["instruments"] as MutableList<String>).contains(instrument)) {
                (musician["instruments"] as MutableList<String>).remove(instrument)
            } else {
                println("Instrument not found!")
            }
        }
        "change_genre" -> {
            print("Enter the new genre: ")
            val genre = readLine()
            musician["genre"] = genre.orEmpty()
        }
        "modify_name" -> {
            print("Enter the new name: ")
            val name = readLine()
            musician["name"] = name.orEmpty()
        }
        else -> println("Invalid modification!")
    }

    return musician
}

val musician = mutableMapOf(
    "name" to ""
)