/**
 * Given a dictionary and a list of values, the task is to iterate over the list and access the corresponding values
 * from the dictionary.
 *
 * @param dictValues A dictionary containing key-value pairs.
 * @param listData A list of values.
 * @return A list of values retrieved from the dictionary based on the keys present in the list.
 */
fun economistCode(dictValues: Map<String, Double>, listData: List<String>): List<Double> {

    // Create an empty list to store the extracted values
    val result = mutableListOf<Double>()

    // Iterate over the list
    for (item in listData) {
        // Check if the item is a key in the dictionary
        if (item in dictValues) {
            // Access the value from the dictionary and append it to the result list
            result.add(dictValues[item]!!)
        }
    }

    return result
}

// Example usage
val sampleDict = mapOf(
    "apple" to 3.99,
    "banana" to 1.99,
    "orange" to 2.49,
    "grapes" to 4.25,
    "watermelon" to 8.99
)

val sampleList = listOf("banana", "grapes", "kiwi", "orange")

val output = economistCode(sampleDict, sampleList)
/**
 * Given a dictionary and a list of values, the task is to iterate over the list and access the corresponding values
 * from the dictionary.
 *
 * @param dictValues A dictionary containing key-value pairs.
 * @param listData A list of values.
 * @return A list of values retrieved from the dictionary based on the keys present in the list.
 */
fun economistCode(dictValues: Map<String, Double>, listData: List<String>): List<Double> {
/**
 * Given a dictionary and a list of values, the task is to iterate over the list and access the corresponding values
 * from the dictionary.
 *
 * @param dictValues A dictionary containing key-value pairs.
 * @param listData A list of values.
 * @return A list of values retrieved from the dictionary based on the keys present in the list.
 */
fun economistCode(dictValues: Map<String, Double>, listData: List<String>): List<Double> {

    // Create an empty list to store the extracted values
    val result = mutableListOf<Double>()

    // Iterate over the list
    for (item in listData) {
        // Check if the item is a key in the dictionary
        if (item in dictValues) {
            // Access the value from the dictionary and append it to the result list
            result.add(dictValues[item]!!)
        }
    }

    return result
}

// Example usage
val sampleDict = mapOf(
    "apple" to 3.99,
    "banana" to 1.99,
    "orange" to 2.49,
    "grapes" to 4.25,
    "watermelon" to 8.99
)

val sampleList = listOf("banana", "grapes", "kiwi", "orange")

val output = economistCode(sampleDict, sampleList)