Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following corresponds to python programming. Will upvote. 1) Write a function, make_dict(keys,values) that performs the following tasks. This function receives two lists keys and
The following corresponds to python programming. Will upvote.
1) Write a function, make_dict(keys,values) that performs the following tasks.
-
This function receives two lists keys and values as arguments.
-
It returns a dictionary using these two lists, pairing corresponding items.
-
The function should test if the number of elements in two lists is the same. If not, it should print "Error: the lengths of two lists are not the same"
a) # Complete the following function BELOW FULLY. DO NOT CHANGE THE FUNCTION NAME AND ARGUMENTS!
def make_dict(keys, values): if len(keys) != else
-------------
# The following code is provided for your test, You can modify it as you want, to test your function. k = ['a','b','c','d'] v = [1,2,3,4] d = make_dict(k,v) print(d) print(' ') k = ['A','B','C'] v = [[1,2,3], ['n','m','p','q','x'], ['USA', 'China', 'Chile', 'Kenya']] d = make_dict(k,v) print(d)
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