如何返回每个国家作为键,以及该国的城市列表作为值?使用字典和嵌入式列表理解?不使用集合
country_city_tuples= [('Netherlands', 'Alkmaar'),
('Netherlands', 'Tilburg'),
('Netherlands', 'Den Bosch'),
('Netherlands', 'Eindhoven'),
('Spain', 'Madrid'),
('Spain', 'Barcelona'),
('Spain', 'Cordoba'),
('Spain', 'Toledo'),
('Italy', 'Milano'),
('Italy', 'Roma')]
你可以这样做:
输出如下:
相关问题 更多 >
编程相关推荐