Objective
Create a Python program that analyzes a JSON with nested data.
Instructions
- Read a line with a JSON object with the keys
country(text) andcities, a list of objects withnameandpopulation(integer). - Convert it with
json.loads. - On the first line show
Most populated: city (population). If there is a tie, the first one in the list. - On the second line show
Total population: T, with the sum of the populations of all the cities.
{"country": "España", "cities": [{"name": "Madrid", "population": 3300000}, {"name": "Sevilla", "population": 680000}, {"name": "Bilbao", "population": 345000}]}
Most populated: Madrid (3300000)
Total population: 4325000
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise