Write a loop that prints each country's population in country_pop. Sample output for the given program:
United States has 318463000 people.
India has 1247220000 people.
Indonesia has 252164800 people.
China has 1365830000 people.
Learn more about our help with Assignments: Python
Comments
Assignment Expert
14.02.18, 15:21
James, no difference in the code, just other variables names.
james
14.02.18, 06:37
for country,pop in country_pop.items(): ##This works.
Assignment Expert
24.01.18, 20:58
$ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0
20160609] on linux Type "help", "copyright", "credits" or "license"
for more information. >>> country_pop={"United States": 318463000,
"India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 }
>>> >>> for key,value in country_pop.items(): print(key +" has "+
str(value) +" people.") ... China has 1365830000 people. India has
1247220000 people. United States has 318463000 people. Indonesia has
25216480 people. >>>
lamar
24.01.18, 20:45
this doesnt work
Leave a comment
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Comments
James, no difference in the code, just other variables names.
for country,pop in country_pop.items(): ##This works.
$ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> country_pop={"United States": 318463000, "India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 } >>> >>> for key,value in country_pop.items(): print(key +" has "+ str(value) +" people.") ... China has 1365830000 people. India has 1247220000 people. United States has 318463000 people. Indonesia has 25216480 people. >>>
this doesnt work
Leave a comment