Hi!
I was wondering if someone could help with writing the code for the following function. I am having trouble with dictionaries and would greatly appreciate some hints!
thanks!
Write a function build_car_maker, which consumes a car registry dictionary, and produces a car maker dictionary, leaving the original dictionary unchanged. The car registry dictionary stores key:value pairs of the form licence_plate:car_maker, where both the key and the value are strings, for example "ABC 123":"Ford".
The new dictionary will be produced from the consumed dictionary, and its key:value pairs will be of the form
car_maker:[licence_plate, licence_plate, ...], i.e. the value associated with the car_maker name is the list of licence plates keys in the original dictionary which have that car_maker as their values.
While the dictionaries themselves are unsorted, the produced dictionary should have the list
of licence plate values stored in alphabetical order (you can use a built-in sorting method to
do this, or write you own helper function).
For example, suppose you have the car registry dictionary cars:
{"ABCD 123":"Mazda", "LFS 000":"Kia", "WINNR":"Ford", "XTRA":"Ford", "UR GR8":"Mazda"}
and you call build_car_maker(car), then the produced dictionary should be:
{"Kia":["LFS 000"], "Ford":["WINNR", "XTRA"], "Mazda":["ABCD 123", "UR GR8"]}
thanks a lot for any help! :)