/**
 * This function calculates the average weight of a group of animals by using loop control statements
 * and the unconditioned ternary operator.
 *
 * @param animals A list of dictionaries representing different animals, where each dictionary contains the 'name'
 * and 'weight' of the animal.
 * @return The average weight of the animals.
 */
fun getAverageWeight(animals: List<Map<String, Any>>): Float {

    var totalWeight = 0f
    var count = 0

    for (animal in animals) {
        // Check if weight key exists in the animal dictionary
        val weight = animal["weight"] as? Float ?: 0f // Unconditioned ternary operator

        totalWeight += weight
        count++
    }

    val averageWeight = if (count != 0) totalWeight / count else 0f // Unconditioned ternary operator

    return averageWeight
}
/**
 * This function calculates the average weight of a group of animals by using loop control statements
 * and the unconditioned ternary operator.
 *
 * @param animals A list of dictionaries representing different animals, where each dictionary contains the 'name'
 * and 'weight' of the animal.
 * @return The average weight of the animals.
 */
fun getAverageWeight(animals: List<Map<String, Any>>): Float {
/**
 * This function calculates the average weight of a group of animals by using loop control statements
 * and the unconditioned ternary operator.
 *
 * @param animals A list of dictionaries representing different animals, where each dictionary contains the 'name'
 * and 'weight' of the animal.
 * @return The average weight of the animals.
 */
fun getAverageWeight(animals: List<Map<String, Any>>): Float {

    var totalWeight = 0f
    var count = 0

    for (animal in animals) {
        // Check if weight key exists in the animal dictionary
        val weight = animal["weight"] as? Float ?: 0f // Unconditioned ternary operator

        totalWeight += weight
        count++
    }

    val averageWeight = if (count != 0) totalWeight / count else 0f // Unconditioned ternary operator

    return averageWeight
}