Question
PYTHON PROBLEM Write a function list_to_dict that takes a list l as its only argument and returns a dictionary populated from the data in l.
PYTHON PROBLEM
Write a function list_to_dict that takes a list l as its only argument and returns a dictionary populated from the data in l. Assuming that the list has the structure l == [key1,value1,key2,value2,key3,value3,...]. list_to_dict will return the dictionary { key1:value1, key2:value2, key3:value3, ...}. Also write the inverse function dict_to_list that takes a dictionary d and returns a list as an alternating series of keys and values like the format of the list l. Your code needs to work for arbitrary-length lists and dictonaries. You can assume that the list l will always have an even length and are not required to check for it.
In [ ]:
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