Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DICTIONARIES 4) 20 points )2 points Create an empty dictionary country big city

ID: 3903521 • Letter: D

Question

DICTIONARIES 4) 20 points )2 points Create an empty dictionary country big city ountry_big city :0 b) 8 points Write a loop to ask for user input for names of country and also its largest city (most people) Add each country and its big_city to the country-big-city dictionary c) 4 points Stop the loop when the user types "Quit" d) 2 points Change user input data so that "united states", "new york" gets stored in the dictionary with key "United States and value "New York" e) 4 points Print the dictionary, one country and big city per line Example: Canada largest city Toronto Japan largest city Tokyo

Explanation / Answer

Solution for the above question is:-

country_big_city = {}

count=True
while (count):
country = input('Enter new country: ')
big_city = input('Enter new big_city: ')
country_big_city[country] = big_city
count = input("Enter 'Quit' if you Want to Quit/Enter anything else if you want to continue : ")
if count == "Quit":
count=False;
  
for c, b in country_big_city.items():
print(c.title(), 'largest city', b.title())

--------------------------------------------------------------------------------------------------------------------------------------------------------

a) country_big_city = {}

b) while (count):
country = input('Enter new country: ')
big_city = input('Enter new big_city: ')

//adding user input

country_big_city[country] = big_city

c) count = input("Enter 'Quit' if you Want to Quit/Enter anything else if you want to continue : ")
if count == "Quit":
count=False;

d)  for c, b in country_big_city.items():
print(c.title(), 'largest city', b.title())

e) for c, b in country_big_city.items():
print(c.title(), 'largest city', b.title())

=====================================================================================

Note ;- .title() method captailize the first letter of the word.

====================================================================================

Thanks for asking...Keep on Chegging...

Please give a thumbs up if u like the solution helpful.... :)