/**
 * This exercise is to create a dictionary by merging two lists.
 * The keys of the resulting dictionary will be the elements from list1
 * and the values will be corresponding elements from list2.
 *
 * Your task is to complete the code below, which should take two lists
 * as arguments, and return the resultant dictionary.
 */
fun createDictionaryFromList(list1: List<String>, list2: List<String>): Map<String, List<String>> {

    val dictionary = mutableMapOf<String, List<String>>()

    // Write a for loop to iterate over list1 and list2 simultaneously
    // and add the elements as key-value pairs to the dictionary
    for (index in list1.indices) {
        val key = list1[index]
        val value = list2[index]
        
        // Check if key already exists in the dictionary
        if (dictionary.containsKey(key)) {
            // If it does, append the new value to existing values
            val existingValues = dictionary.getValue(key).toMutableList()
            existingValues.add(value)
            dictionary[key] = existingValues
        } else {
            // If it doesn't, create a new entry with key and value
            dictionary[key] = listOf(value)
        }
    }

    return dictionary
}
/**
 * This exercise is to create a dictionary by merging two lists.
 * The keys of the resulting dictionary will be the elements from list1
 * and the values will be corresponding elements from list2.
 *
 * Your task is to complete the code below, which should take two lists
 * as arguments, and return the resultant dictionary.
 */
fun createDictionaryFromList(list1: List<String>, list2: List<String>): Map<String, List<String>> {
/**
 * This exercise is to create a dictionary by merging two lists.
 * The keys of the resulting dictionary will be the elements from list1
 * and the values will be corresponding elements from list2.
 *
 * Your task is to complete the code below, which should take two lists
 * as arguments, and return the resultant dictionary.
 */
fun createDictionaryFromList(list1: List<String>, list2: List<String>): Map<String, List<String>> {

    val dictionary = mutableMapOf<String, List<String>>()

    // Write a for loop to iterate over list1 and list2 simultaneously
    // and add the elements as key-value pairs to the dictionary
    for (index in list1.indices) {
        val key = list1[index]
        val value = list2[index]
        
        // Check if key already exists in the dictionary
        if (dictionary.containsKey(key)) {
            // If it does, append the new value to existing values
            val existingValues = dictionary.getValue(key).toMutableList()
            existingValues.add(value)
            dictionary[key] = existingValues
        } else {
            // If it doesn't, create a new entry with key and value
            dictionary[key] = listOf(value)
        }
    }

    return dictionary
}