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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started