How many countries do not have "a" in their names?

Saw the question posted online and decided to see if I can solve the question with Python programming.

30 minute later ....

source: http://www.countries-list.info/Download-List/download
Setup, copy the contents in the link above and and save it as country3.xml file in the same directory where the python script resides.


import urllib
import xml.etree.ElementTree as ET

data = urllib.urlopen('country3.xml').read()
tree = ET.fromstring(data)
lst = tree.findall('./option') #to get country counts and lists
convert_string__to_list = list()
cnt = 1
for item in lst:
    if 'a' not in item.get('label').lower():
        convert_string__to_list.append(item.get('label'))
        print cnt, ")", item.get('label')
        cnt = cnt + 1
print "Number of countries without 'a' in the name are ", cnt-1, "out of " , len(lst) , "countries."


Output should look like this ..


1 ) Belgium
2 ) Belize
3 ) Benin
4 ) Brunei
5 ) Burundi
6 ) Chile
7 ) Comoros
8 ) Cyprus
9 ) Czech Republic
10 ) Cote d%’Ivoire
11 ) Djibouti
12 ) Egypt
13 ) Fiji
14 ) French Southern Territories
15 ) Greece
16 ) Guernsey
17 ) Jersey
18 ) Lesotho
19 ) Liechtenstein
20 ) Luxembourg
21 ) Mexico
22 ) Montenegro
23 ) Morocco
24 ) Niger
25 ) Niue
26 ) Peru
27 ) Philippines
28 ) Puerto Rico
29 ) RĂ©union
30 ) Seychelles
31 ) Sweden
32 ) Timor-Leste
33 ) Togo
34 ) Turkey
35 ) United Kingdom
36 ) Yemen
Number of countries without 'a' in the name are  36 out of  265 countries.