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:
- There is a single key for each character (in Hamilton) or airport (in flights).
- 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
Get step-by-step solutions from verified subject matter experts
