How would I put the following information into a Python dictionary — http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html? Keys would be the country and values would be the two-character ISO code.
For example, I want the result to be:
mapping_of_country_to_iso = {'AALAND ISLANDS':'AX','AFGHANISTAN':'AF',...}
I just copied and pasted the important data into a text file called ‘countries.txt’ then did something like this:
It’s probably not the “best” way to do it, but it seems to work.
Here it is following John Machin’s helpful recommendations: