Question: (PYTHON problem!) Write the function listsToDict that will take two list and convert them to a dictionary and return the dictionary. The values of the
(PYTHON problem!) Write the function listsToDict that will take two list and convert them to a dictionary and return the dictionary.
The values of the first list will become the keys whereas the values of
second list will hold the values.
EXAMPLE PROGRAM RUN
li1 = [1,2,3]
li2 = ['first','second','third']
INPUT:
listsToDict(li1, li2)
OUTPUT:
{'1': 'first', '2': 'second', '3': 'third'}
INPUT:
listsToDict(li2, li1)
OUTPUT:
{'first': 1, 'second': 2, 'third': 3}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
