In python,
Create a dictionary that maps countries to their capitals. You may start with an empty dictionary. Ask the user to input the name of the country and its capital and add them to the dictionary. E.g.. capitals = {'Argentina Buenos Aires'. 'France":"Paris'. 'US': 'Washington D.C.'} Once the dictionary is created, print the countries, in alphabetical order, and the capitals. Here is a sample run: Enter a country and a capital com Enter a country and a capital comma separated (Q to quit): France.Paris Enter a country and a capital comma separated (Q to quit): United States.Washington D.C. Enter a country and a capital comma separated (Q to quit): Spain Madrid Enter a country and a capital comma separated (Q to quit): Q COUNTRY France Japan Spain United States omma separated (Q to quit): Japan, Tokyo CAPITAL Paris Tokyo Madrid Washington D.C. |
In python,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am