Question: Create a function in Python that takes a list of 2-tuples and convert the list to a dictionary. The formart of the list is: [(k1,

Create a function in Python that takes a list of 2-tuples and convert the list to a dictionary. The formart of the list is: [(k1, v1), (k2, v2), (k3, v3)] and the output is {k1:v1, k2:v2, k3:v3}. An example of a test case is [("Riti" , 11), ("Aadi" , 12), ("Sam" , 13),("John" , 22),("Lucy" , 90)].

def list_to_dict(a_list):

"""list to dict here"""

return a_list

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!