Created
October 31, 2012 03:57
-
-
Save garthhumphreys/3984709 to your computer and use it in GitHub Desktop.
Print to screen a random country
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
import random | |
def main(): | |
""" | |
This script randomly prints to screen a soverign country from a list of 206 countries | |
""" | |
try: | |
allcountries = open('allCountries.txt','r') | |
clist = allcountries.read() | |
clist = clean_list(clist) | |
print random.choice(clist) | |
except: | |
print 'A problem occurred' | |
def clean_list(list): | |
_list = list | |
clean_list = _list.split('\n') | |
return clean_list | |
if __name__ == '__main__': | |
main() | |
""" | |
Here is the list of countries | |
Afghanistan | |
Albania | |
Algeria | |
Andorra | |
Angola | |
Antigua and Barbuda | |
Argentina | |
Armenia | |
Australia | |
Austria | |
Azerbaijan | |
Bahamas | |
Bahrain | |
Bangladesh | |
Barbados | |
Belarus | |
Belgium | |
Belize | |
Benin | |
Bhutan | |
Bolivia | |
Bosnia and Herzegovina | |
Botswana | |
Brazil | |
Brunei | |
Bulgaria | |
Burkina Faso | |
Burma | |
Burundi | |
Cambodia | |
Cameroon | |
Canada | |
Cape Verde | |
Central African Republic | |
Chad | |
Chile | |
China | |
Colombia | |
Comoros | |
Congo, Democratic Republic of the | |
Congo, Republic of the | |
Costa Rica | |
Côte d'Ivoire | |
Croatia | |
Cuba | |
Cyprus | |
Czech Republic | |
Denmark | |
Djibouti | |
Dominica | |
Dominican Republic | |
East Timor | |
Ecuador | |
Egypt | |
El Salvador | |
Equatorial Guinea | |
Eritrea | |
Estonia | |
Ethiopia | |
Fiji | |
Finland | |
France | |
Gabon | |
The Gambia | |
Georgia | |
Germany | |
Ghana | |
Greece | |
Grenada | |
Guatemala | |
Guinea | |
Guinea-Bissau | |
Guyana | |
Haiti | |
Honduras | |
Hungary | |
Iceland | |
India | |
Indonesia | |
Iran | |
Iraq | |
Ireland | |
Israel | |
Italy | |
Jamaica | |
Japan | |
Jordan | |
Kazakhstan | |
Kenya | |
Kiribati | |
Korea, North | |
Korea, South | |
Kuwait | |
Kyrgyzstan | |
Laos | |
Latvia | |
Lebanon | |
Lesotho | |
Liberia | |
Libya | |
Liechtenstein | |
Lithuania | |
Luxembourg | |
Macedonia | |
Madagascar | |
Malawi | |
Malaysia | |
Maldives | |
Mali | |
Malta | |
Marshall Islands | |
Mauritania | |
Mauritius | |
Mexico | |
Micronesia, Federated States of | |
Moldova | |
Monaco | |
Mongolia | |
Montenegro | |
Morocco | |
Mozambique | |
Namibia | |
Nauru | |
Nepal | |
Netherlands | |
New Zealand | |
Nicaragua | |
Niger | |
Nigeria | |
Norway | |
Oman | |
Pakistan | |
Palau | |
Panama | |
Papua New Guinea | |
Paraguay | |
Peru | |
Philippines | |
Poland | |
Portugal | |
Qatar | |
Romania | |
Russia | |
Rwanda | |
Saint Kitts and Nevis | |
Saint Lucia | |
Saint Vincent and the Grenadines | |
Samoa | |
San Marino | |
São Tomé and Príncipe | |
Saudi Arabia | |
Senegal | |
Serbia | |
Seychelles | |
Sierra Leone | |
Singapore | |
Slovakia | |
Slovenia | |
Solomon Islands | |
Somalia | |
South Africa | |
South Sudan | |
Spain | |
Sri Lanka | |
Sudan | |
Suriname | |
Swaziland | |
Sweden | |
Switzerland | |
Syria | |
Tajikistan | |
Tanzania | |
Thailand | |
Togo | |
Tonga | |
Trinidad and Tobago | |
Tunisia | |
Turkey | |
Turkmenistan | |
Tuvalu | |
Uganda | |
Ukraine | |
United Arab Emirates | |
United Kingdom | |
United States | |
Uruguay | |
Uzbekistan | |
Vanuatu | |
Vatican City | |
Venezuela | |
Vietnam | |
Yemen | |
Zambia | |
Zimbabwe | |
Abkhazia | |
Cook Islands | |
Kosovo | |
Nagorno-Karabakh | |
Niue | |
Northern Cyprus | |
Palestine | |
Sahrawi Arab Democratic Republic | |
Somaliland | |
South Ossetia | |
Taiwan | |
Transnistria | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment