1
+ from typing import Dict , List
2
+
3
+ cars = {
4
+ 'Ford' : ['Falcon' , 'Focus' , 'Festiva' , 'Fairlane' ],
5
+ 'Holden' : ['Commodore' , 'Captiva' , 'Barina' , 'Trailblazer' ],
6
+ 'Nissan' : ['Maxima' , 'Pulsar' , '350Z' , 'Navara' ],
7
+ 'Honda' : ['Civic' , 'Accord' , 'Odyssey' , 'Jazz' ],
8
+ 'Jeep' : ['Grand Cherokee' , 'Cherokee' , 'Trailhawk' , 'Trackhawk' ]
9
+ }
10
+ DEFAULT_SEARCH = "trail"
11
+ CarsType = Dict [str , List [str ]]
12
+
13
+
14
+ def main ():
15
+ print (get_all_jeeps (cars ))
16
+
17
+
18
+
19
+
20
+ def get_all_jeeps (cars : CarsType = cars ) -> str :
21
+ """
22
+ Retrieve the 'Jeep' models from the cars dict and join them by a
23
+ comma and space (', '). Leave the original ordering intact.
24
+ """
25
+ jeeps = ", " .join (cars ["Jeep" ])
26
+ return jeeps
27
+
28
+
29
+ def get_first_model_each_manufacturer (cars : CarsType = cars ) -> List [str ]:
30
+ """
31
+ Loop through the cars dict filtering out the first model for each
32
+ manufacturer. Return the matching models in a list leaving the original
33
+ ordering intact.
34
+ """
35
+ pass
36
+
37
+
38
+ def get_all_matching_models (
39
+ cars : CarsType = cars , grep : str = DEFAULT_SEARCH
40
+ ) -> List [str ]:
41
+ """
42
+ Return a list of all models containing the case insensitive
43
+ 'grep' string which defaults to DEFAULT_SEARCH ('trail').
44
+ Sort the resulting sequence alphabetically
45
+ """
46
+ pass
47
+
48
+
49
+ def sort_car_models (cars : CarsType = cars ) -> CarsType :
50
+ """
51
+ Loop through the cars dict returning a new dict with the
52
+ same keys and the values sorted alphabetically.
53
+ """
54
+ pass
55
+
56
+
57
+ if __name__ == "__main__" :
58
+ main ()
0 commit comments