Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39328 > unrolled thread
| Started by | Morten Engvoldsen <mortenengv@gmail.com> |
|---|---|
| First post | 2013-02-20 10:24 +0100 |
| Last post | 2013-02-20 10:24 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Verification of bank number using modulus 11 Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-20 10:24 +0100
| From | Morten Engvoldsen <mortenengv@gmail.com> |
|---|---|
| Date | 2013-02-20 10:24 +0100 |
| Subject | Re: Verification of bank number using modulus 11 |
| Message-ID | <mailman.2091.1361352273.2939.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
Hi,
Thanks for below code:
After this code:
isbn = isbn[:-1]
if len(isbn) != 10:
return False
Add:
if isbn[4:6] == "00":
isbn = isbn[6:]
It is working exactly how it should :)
I didn't even change that part . The zip function automatically truncates
to the length of the shorter input sequence.
Thanks a lot again :)
Have a nice day..
On Tue, Feb 19, 2013 at 11:59 PM, Morten Engvoldsen <mortenengv@gmail.com>wrote:
> Hi Team,
> Thanks for the code.
> I have altered the code with below code, it is able to validate the
> number now,
>
> def calc_checkdigit(isbn):
> isbn = isbn.replace(".", "")
> check_digit = int(isbn[-1])
> isbn = isbn[:-1]
> if len(isbn) != 10:
> return False
> weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
> result = sum(w * (int(x)) for w, x in zip(weights, isbn))
> remainder = result % 11
> if remainder == 0:
> check = 0
> else:
> check = 11 - remainder
> return check == check_digit
>
> calc_checkdigit(""8601.11.**17947"")
>
>
> But can you tell me how could i implement below
>
> "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."
>
> which means if account number is "8601.00.**17947" then check digit is
> calculate as
>
> result = (1*5) + (7*4)+ (9*3)+(4*2)
>
> remainder = result % 11
>
> check_digit = 11 - remainder
>
> Can you tell me how can i implement this ?
>
>
>
>
>
>
>
Back to top | Article view | comp.lang.python
csiph-web