I have a list of countries like:
countries=[\'American Samoa\', \'Canada\', \'France\'...]
I want to convert them like this:
There are a few things to consider with Country Names, especially if using them as search keys. They can be in Title Case (what we think of as normal) or Uppercase (from ISO 3166). Names that include commas or apostrophes might need to be wrapped in quotes. Some names have letters with accents (so non-ASCII). However, there might be a combination that works for you at http://www.dataphyx.com/countrynames/ where you can get CSV lists of ISO Names/IDs in various formats.