The problem. Find all the countries in the world without an ‘A’ in their name.
def remove_country_line_numbers():
return [l.strip() for l in open('countries.txt').readlines() \
if not l.strip().isdigit() and l.lower().find('a')==-1]
Usage:
In [81]: ", ".join(remove_country_line_numbers())
Out[81]: "Belgium, Belize, Benin, Brunei, Burundi, Chile, Comoros, Congo,
Republic of the, Cote d'Ivoire, Cyprus, Czech Republic, Djibouti, Egypt,
Fiji, Greece, Guernsey, Hong Kong, Jersey, Lesotho, Liechtenstein, Luxembourg,
Mexico, Morocco, Niger, Niue, Peru, Philippines, Puerto Rico, Reunion, Seychelles,
Sweden, Timor-Leste, Togo, Turkey, United Kingdom, Yemen"