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: 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: References: Date: Wed, 20 Feb 2013 10:24:31 +0100 Subject: Re: Verification of bank number using modulus 11 From: Morten Engvoldsen 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --f46d04427194934edf04d624860a Content-Type: text/plain; charset=ISO-8859-1 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 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 ? > > > > > > > --f46d04427194934edf04d624860a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,
Thanks for below code:
After this code:

isbn =3D isbn[:-1]
if len(isbn) !=3D 10:
=A0 return False

Add:

if isbn[4:6] =3D=3D "00":
=A0 =A0 isbn =3D isbn[6:]

It is working exactly how it should :) I didn't even change that part . =A0The zip function automatically tru= ncates to the length of the shorter input sequence.

Thanks a lot aga= in :)

Have a nice day..


On Tue, Feb 19, 2013 at 11:59 PM, Morten Eng= voldsen <mortenengv@gmail.com> wrote:
Hi Team,
Thanks for the code.
=A0I have altered th= e code with below code, it is able to validate the number now,
=A0
def calc_checkdigit(isbn):
isbn =3D isbn.repla= ce(".", "")
check_digit =3D int(isbn[-1])
isbn =3D isbn[:-1]
= if len(isbn) !=3D 10:
=A0 return False
=
weights =3D [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
result =3D sum(w * (int(= x)) for w, x in zip(weights, isbn))
remainder =3D result % 11
if remainder =3D=3D 0:
=A0=A0 check = =3D 0
else:
=A0=A0=A0check =3D 11 - remainder
return check =3D=3D check_digit
=A0
calc_checkdigit(&q= uot;"8601.11.17947"")
=A0
=A0
But can you tell me how could i implement = below

"If digits 5 and 6 of the acc= ount number are zeros, the check digit is calculated on the 7, 8, 9 and 10t= h digit of the account number."

which means if account number is "8601.00.<= /u>17947" then check digit is calculate as=A0

=A0= result =3D (1*5) + (7*4)+ (9*3)+(4*2)

remainder =3D re= sult % 11

check_digit =3D 11 - remainder

Can you tell me how can= i implement this ?

=A0


=A0

=A0

--f46d04427194934edf04d624860a--