Αποτελέσματα Αναζήτησης
6.16.1: Report country population. Cannot retrieve latest commit at this time. user_input = input () entries = user_input.split (',') country_pop = {} for pair in entries: split_pair = pair.split (':') country_pop [split_pair [0]] = split_pair [1] # country_pop is a dictionary, Ex: { 'Germany':'82790000', 'France':'67190000' } for country in ...
print (country, 'has', pop, 'people.') Answer: The items () method of the country_pop dictionary can be utilized to traverse over the pairs that is key and value in the for loop. Every pair that is key-value is.
This solution use a for loop to traverse over each element in country pop, a dictionary storing each country's population. The loop gives each entry's country name and population to the variables 'country' and 'pop'. It then outputs a statement with the format 'Country has Population people.'.
CHALLENGE 6.16.1: Report country population. АCTVITY 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.
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':China has 1365830000 people.
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.
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.