Problem #4: Find the Most Populous Country on Each Continent Write a function findMostPopulousCountry that takes the var
Posted: Wed Apr 27, 2022 3:13 pm
Problem #4: Find the Most Populous Country on Each Continent
Write a function findMostPopulousCountry that takes the variables
“data” and “continents” (returned by the first two functions above
respectively) and returns a list containing the most populous
country on each continent. Call the function and print the list
returned. The list should be in the same order as the continents
appear in the “continents” list. So, for instance, if “Europe” is
the first item in your list of continents, then the most populous
country in Europe should be first in the list returned by
findMostPopulousCountry. Hint: you will need to keep a list
containing the highest population found on each continent so far,
as you search through the data.
language: Python
Write a function findMostPopulousCountry that takes the variables
“data” and “continents” (returned by the first two functions above
respectively) and returns a list containing the most populous
country on each continent. Call the function and print the list
returned. The list should be in the same order as the continents
appear in the “continents” list. So, for instance, if “Europe” is
the first item in your list of continents, then the most populous
country in Europe should be first in the list returned by
findMostPopulousCountry. Hint: you will need to keep a list
containing the highest population found on each continent so far,
as you search through the data.
language: Python