Verification of bank number using modulus 11
Morten Engvoldsen
mortenengv at gmail.com
Tue Feb 19 15:50:18 EST 2013
Hi Team,
I am trying to verify the account number using the following algorithm:
"The valid account number is 11 numeric digit without seperator. Eg.
86011117947 is a valid account number. All banks apply a modulus-based
method for the validation of the account structure. The 10-digit account
number is multiplied from left to right by the following weights: 5, 4, 3,
2, 7, 6, 5, 4, 3, 2. The resulting numbers are added up and divided by 11.
The remainder is subtracted from 11 and becomes the check digit. If the
remainder is 0, the check digit will be 0. If digits 5 and 6 of the account
number are zeros, the check digit is calculated on the 7, 8, 9 and 10th
digit of the account number. Account numbers for which the remainder is 1
(check digit 10) cannot be used."
I am trying to validate the Norway account number using the algorithm
mentioned in the following document:
http://www.cnb.cz/miranda2/export/sites/www.cnb.cz/cs/platebni_styk/iban/download/TR201.pdf
Here is my code:
def calc_checkdigit(isbn):
isbn = isbn.replace(".", "")
check_digit = int(isbn[-1])
isbn = isbn[:-1]
if len(isbn) != 10:
return False
result = sum((10 - i) * (int(x) if x != 'X' else 10) for i, x in
enumerate(isbn))
return (result % 11) == check_digit
calc_checkdigit(""8601.11.17947"")
In my program : it is calculating 10 digit with weights 10-1, but according
to above algorithm the weights should be : 5, 4, 3, 2, 7, 6, 5, 4, 3, 2.
Could you please let me know how can i calculate the 10 digit with weights
5, 4, 3, 2, 7, 6, 5, 4, 3, 2. I am using python 2.7.
Thanks in advance team for help..
):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130219/aec1f7bb/attachment.html>
More information about the Python-list
mailing list