/**
 * Given an athlete list and an index, this function checks if the athlete at the specified index
 * is a basketball player and returns their team name. If the athlete is not a basketball player,
 * it returns null.
 *
 * @param athleteList A list of athlete names.
 * @param index The index of the athlete to check.
 * @return The team name if the athlete at the specified index is a basketball player, null otherwise.
 */
fun nestedIfNegativeIndexing(athleteList: List<String>, index: Int): String? {

    if (index < 0) {  // Check if index is negative
        if (index >= -athleteList.size) {  // Check if negative index is within range
            if (athleteList[index].contains("Basketball")) {  // Check if athlete at negative index is a basketball player
                return athleteList[index].split(" - ")[1]  // Return the team name
            }
        }
        return null
    } else {
        return null
    }
}
/**
 * Given an athlete list and an index, this function checks if the athlete at the specified index
 * is a basketball player and returns their team name. If the athlete is not a basketball player,
 * it returns null.
 *
 * @param athleteList A list of athlete names.
 * @param index The index of the athlete to check.
 * @return The team name if the athlete at the specified index is a basketball player, null otherwise.
 */
fun nestedIfNegativeIndexing(athleteList: List<String>, index: Int): String? {
/**
 * Given an athlete list and an index, this function checks if the athlete at the specified index
 * is a basketball player and returns their team name. If the athlete is not a basketball player,
 * it returns null.
 *
 * @param athleteList A list of athlete names.
 * @param index The index of the athlete to check.
 * @return The team name if the athlete at the specified index is a basketball player, null otherwise.
 */
fun nestedIfNegativeIndexing(athleteList: List<String>, index: Int): String? {

    if (index < 0) {  // Check if index is negative
        if (index >= -athleteList.size) {  // Check if negative index is within range
            if (athleteList[index].contains("Basketball")) {  // Check if athlete at negative index is a basketball player
                return athleteList[index].split(" - ")[1]  // Return the team name
            }
        }
        return null
    } else {
        return null
    }
}