/**
 * Given a dictionary 'athleteData" containing information about an athlete
 * and a dictionary 'newData" with additional information about the athlete,
 * this function appends the new data to the existing athlete data
 * and removes any duplicate keys in the process.
 *
 * @param athleteData The dictionary containing existing athlete data.
 * @param newData The dictionary containing additional athlete data.
 * @return The updated athlete data with new information appended.
 * @throws IllegalArgumentException If the input arguments are not dictionaries,
 *                                  or if the athlete data is empty.
 */
fun appendRemoveAthleteData(athleteData: MutableMap<String, Any>, newData: Map<String, Any>): MutableMap<String, Any> {

    if (athleteData !is MutableMap<*, *> || newData !is Map<*, *>) {
        throw IllegalArgumentException("Input arguments must be dictionaries")
    }
    if (athleteData.isEmpty()) {
        throw IllegalArgumentException("Athlete data cannot be empty")
    }

    try {
        for ((key, value) in newData) {
            athleteData[key as String] = value
        }
    } catch (e: Exception) {
        println("An unexpected error occurred while appending new data: $e")
    }

    return athleteData
}
/**
 * Given a dictionary 'athleteData" containing information about an athlete
 * and a dictionary 'newData" with additional information about the athlete,
 * this function appends the new data to the existing athlete data
 * and removes any duplicate keys in the process.
 *
 * @param athleteData The dictionary containing existing athlete data.
 * @param newData The dictionary containing additional athlete data.
 * @return The updated athlete data with new information appended.
 * @throws IllegalArgumentException If the input arguments are not dictionaries,
 *                                  or if the athlete data is empty.
 */
fun appendRemoveAthleteData(athleteData: MutableMap<String, Any>, newData: Map<String, Any>): MutableMap<String, Any> {
/**
 * Given a dictionary 'athleteData" containing information about an athlete
 * and a dictionary 'newData" with additional information about the athlete,
 * this function appends the new data to the existing athlete data
 * and removes any duplicate keys in the process.
 *
 * @param athleteData The dictionary containing existing athlete data.
 * @param newData The dictionary containing additional athlete data.
 * @return The updated athlete data with new information appended.
 * @throws IllegalArgumentException If the input arguments are not dictionaries,
 *                                  or if the athlete data is empty.
 */
fun appendRemoveAthleteData(athleteData: MutableMap<String, Any>, newData: Map<String, Any>): MutableMap<String, Any> {

    if (athleteData !is MutableMap<*, *> || newData !is Map<*, *>) {
        throw IllegalArgumentException("Input arguments must be dictionaries")
    }
    if (athleteData.isEmpty()) {
        throw IllegalArgumentException("Athlete data cannot be empty")
    }

    try {
        for ((key, value) in newData) {
            athleteData[key as String] = value
        }
    } catch (e: Exception) {
        println("An unexpected error occurred while appending new data: $e")
    }

    return athleteData
}