The structure of an ISIN is composed of three components:
Alpha-2 code of the country (2 letter code)
A nine-character alphanumeric security identifier
A single check digit.
The check digit is used to help ensure the authenticity of the ISIN. But how is it calculated?
The basic idea is to establish a numerical value for every capital letter in the alphabet. Here is a table with the official conversions:
Software Engineers will recognize these numbers: they are equal to the ASCII code for each capital letter minus 55. For instance, the ASCII code for 'A' is 65, 'B' is 66, and so forth. According to the ISIN.org, the algorithm should follow the below calculations:
Convert any alphabetic letters to their numeric equivalents using the above table.
Beginning with the least significant digit (on the right), multiply every other digit by 2.
Add up the resulting digits, calling the result SUM.
Find the smallest number ending with a zero that is greater than or equal to SUM, and call it VALUE.
Subtract SUM from VALUE, giving the check digit.
The technical term for the check digit is the ten's complement of the sum modulo 10. In English, this means the resulting sum, including the check digit, is a multiple of 10.
Based on the above algorithm wording, these can be coded in the below way for Python or any other programming language.
I hope this was helpful and if you need any help or have any questions, please contact me.