Question: (Python) Create a function named createDict that takes in two input parameters. The first input parameter is a list objects to be used as dictionary

(Python)

Create a function named "createDict" that takes in two input parameters. The first input parameter is a list objects to be used as dictionary keys. The second input parameter is a list of objects to be used as those keys' values. For example, calling createDict(['a', 1, 'w'], [[1,2,3], 'y', True]) would return {'a': [1,2,3], 1: 'y', 'w': True}

*you can assume that all the objects passed in the first parameter (the keys), will be valid dictionary keys - meaning they are all immutable types. This is important since a mutable object, like a list, can not be a dictionary key. The size of these two lists may not be the same. If there is no corresponding item in values for a given key, then the key's value should be -1 (integer). On the other hand, if there is no key for a given value, then the key should be # the string "unnamed" plus the index of the value in the values' list, e.g. 'unnamed3'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!