Question: (D). Data to Dictionary Write a function called data_to_dictionary that converts the data into a dictionary such that: There is a single key for each

(D). Data to Dictionary

Write a function called data_to_dictionary that converts the data into a dictionary such that:

  1. There is a single key for each character (in Hamilton) or airport (in flights).
  2. The value corresponding to each key is a list of the characters/airports to which that key links. The list should contain repeats if there are multiple links.

Here's an example of the desired behavior on a fake data set.

data = [("a", "b"), ("a", "b"), ("a", "c"), ("b", "c"), ("b", "a")] data_to_dictionary(data) # output {"a" : ["b", "b", "c"], "b" : ["a", "c"]}

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!