【发布时间】:2019-10-10 00:15:56
【问题描述】:
如何将每个国家/地区作为键返回,并将该国家/地区的城市列表作为值返回?使用字典和嵌入式列表理解?不使用集合
country_city_tuples= [('Netherlands', 'Alkmaar'),
('Netherlands', 'Tilburg'),
('Netherlands', 'Den Bosch'),
('Netherlands', 'Eindhoven'),
('Spain', 'Madrid'),
('Spain', 'Barcelona'),
('Spain', 'Cordoba'),
('Spain', 'Toledo'),
('Italy', 'Milano'),
('Italy', 'Roma')]
【问题讨论】:
-
发布你的尝试。我们不是来做你的功课的。
标签: python list tuples list-comprehension dictionary-comprehension