Write a loop that prints each country's population in country_pop. Sample output with input: 'China:1365830000,India:1247220000,United States:318463000,Indonesia:252164800': United States has 318463000 people. India has 1247220000 people. Indonesia has 252164800 people. China has 1365830000 people.

Respuesta :

Answer:

The correct code is for country,pop in country_pop.items():  

   print(country, 'has', pop, 'people.')

Explanation:

country_pop={"United States": 318463000, "India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 }

for key value in country_pop.items(): print(key +" has "+ str(value) +" people.")

The loop that prints each country's population is as follows:

country_population ={"United States": 318463000, "India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 }

for key, value in country_population.items():

   print(key +" has "+ str(value) +" people.")

Code explanation

The code is written in python.

  • The variable "country_population" is used to store each countries and its population. it is a dictionary with key-value pairs. The keys are string(countries) while the values are integers.
  • Then a for loop is used to loop through the key-value pairs of the country_populations.
  • Finally, we print the countries and its population.

learn more on python here: https://brainly.com/question/551803

Ver imagen vintechnology