Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39328
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <mortenengv@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; '"if': 0.09; '8bit%:2': 0.09; 'subject:number': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '11:59': 0.16; 'altered': 0.16; 'day..': 0.16; 'isbn': 0.16; 'sequence.': 0.16; 'truncates': 0.16; 'wrote:': 0.17; 'team,': 0.18; 'code,': 0.18; 'input': 0.18; 'feb': 0.19; 'code.': 0.20; 'email addr:gmail.com>': 0.20; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'skip:& 10': 0.29; 'function': 0.30; 'code': 0.31; 'implement': 0.32; 'could': 0.32; '"")': 0.33; 'shorter': 0.33; 'code:': 0.33; 'hi,': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'false': 0.35; 'pm,': 0.35; 'but': 0.36; "didn't": 0.36; 'should': 0.36; 'subject:: ': 0.38; 'skip:" 10': 0.40; 'skip:n 10': 0.63; 'validate': 0.65; 'account': 0.67; '8bit%:21': 0.69; '10th': 0.84; '2013': 0.84; 'add:': 0.84; 'subject:Verification': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=h0WKfwCzFmLXBMRAFp/d5Ui7FqThNIGQLw8KLqk/LHk=; b=PwyOpdEOaxGGUJqzahfWJtX3elsKUTDDEveezJlrqG3U2LFOZtRGf5uHEeM7sO0t5q DjmbfxYvdLg3bsBYVQMypBojIKcspF1E/F/eT3Ds60WgOnr8XdCRitmdgym7x8zSqosb uR0MTaioLvTMgkBjNSR+MWRltNHhASWFQkxPBd3/QATguALGed5JuASURud6yjnuxfpi wMS8p4N+5DlpznDOhW2wT8TYPuV7Po1AlL64+deR/96P4YJEvqnTMaeINEVBlUeAvUBE nMfM/D+SKO9umZliRUu815n9QMFqdFG4VbBrvDC+qyY/Q8WQC9dXpomSUJbO/azbqa8a 8NlQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.84.162 with SMTP id a2mr30737271wiz.14.1361352271810; Wed, 20 Feb 2013 01:24:31 -0800 (PST) |
| In-Reply-To | <CAJ2vgs4rPwYyA-V4eWZaVVHEkmWEZj+QSMV3eNJTCD6ALwg23w@mail.gmail.com> |
| References | <CAJ2vgs5uzr1BHF-koYmb5s0tBSkzChTKSQ8k=pCkVC21LWXoAQ@mail.gmail.com> <CAJ2vgs4rPwYyA-V4eWZaVVHEkmWEZj+QSMV3eNJTCD6ALwg23w@mail.gmail.com> |
| Date | Wed, 20 Feb 2013 10:24:31 +0100 |
| Subject | Re: Verification of bank number using modulus 11 |
| From | Morten Engvoldsen <mortenengv@gmail.com> |
| To | ian.g.kelly@gmail.com |
| Content-Type | multipart/alternative; boundary=f46d04427194934edf04d624860a |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2091.1361352273.2939.python-list@python.org> (permalink) |
| Lines | 135 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361352273 news.xs4all.nl 6937 [2001:888:2000:d::a6]:39877 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39328 |
Show key headers only | View raw
[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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Verification of bank number using modulus 11 Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-20 10:24 +0100
csiph-web