Question: zyBooks My library > IT 140: Introduction to Scripting v3 home > zyBooks catalog ? Help/FAQ 6.16: Iterating over a dictionary CHALLENGE ACTIVITY 6.16.1: Report

zyBooks My library > IT 140: Introduction to Scripting v3 home > zyBooks catalog ? Help/FAQ 6.16: Iterating over a dictionary CHALLENGE ACTIVITY 6.16.1: Report country population. 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. 247772.2309728.qx3zqy7 1 user_input = input() 1 test 2 entries = user_input . split(' , ') passed 3 country_pop = {} 4 All tests 5 for pair in entries: passed 6 split_pair = pair . split(' : ') country_pop [split_pair[0]] = split_pair[1] 8 # country_pop is a dictionary, Ex: { 'Germany': '82790000', 'France': '67190000' } 9 " "Your solution goes here' ' 10 11 print(country, 'has', pop, 'people. ')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
