Displays capital city of any country. capitals
requires nothing more than
a standard Python 3 installation.
TODO: Add installation instructions
This program can be imported into other Python programs or run from the commandline.
There are two ways to run capitals.py
.
python capitals.py
OR- Run it as an executable. On Unix based systems do:
$ chmod +x capitals.py
And then do:$ ./capitals.py <country name>
For detailed help information:
$ ./capitals.py --help
usage: capitals [country]
Displays capital city of specified country.
positional arguments:
country Displays the capital of country.
optional arguments:
-h, --help show this help message and exit
To use the program as a module, import capitals
into your code.
Call the capitals.capital()
function and pass a country to it as an argument.
The capital()
function will return the capital of that country or a 0 if an invalid
country was passed to it. Capitalisation does not matter.
>>> capitals.capital("Wakanda")
0
>>> capitals.capital("Germany")
'Berlin'
>>> capitals.capital("Japan")
'Tokyo'
>>> capitals.capital("North Korea")
'Pyongyang'
>>> capitals.capital("lithuania")
'Vilnius'
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
The License is here