Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39272 > unrolled thread

Verification of bank number using modulus 11

Started byMorten Engvoldsen <mortenengv@gmail.com>
First post2013-02-19 21:50 +0100
Last post2013-02-19 21:50 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Verification of bank number using modulus 11 Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-19 21:50 +0100

#39272 — Verification of bank number using modulus 11

FromMorten Engvoldsen <mortenengv@gmail.com>
Date2013-02-19 21:50 +0100
SubjectVerification of bank number using modulus 11
Message-ID<mailman.2060.1361307023.2939.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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..







):

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web