Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39603
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.051 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'elif': 0.04; '22,': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '>>': 0.16; '0).': 0.16; 'int(x)': 0.16; 'left:': 0.16; 'subject:issue': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'email addr:gmail.com>': 0.20; 'together.': 0.21; '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; 'correct': 0.28; 'fixed': 0.28; 'leaves': 0.29; 'mod': 0.29; 'fri,': 0.30; 'code': 0.31; 'subject:Number': 0.33; 'hi,': 0.33; 'skip:& 20': 0.33; 'changed': 0.34; 'received:google.com': 0.34; 'wrong': 0.34; 'clear': 0.35; 'false': 0.35; 'pm,': 0.35; 'add': 0.36; 'subject:: ': 0.38; 'instead': 0.39; 'provide': 0.62; 'more': 0.63; 'number:': 0.65; 'results': 0.65; 'total': 0.65; 'validate': 0.65; 'sum': 0.66; '11.': 0.81; '11:': 0.84; '2013': 0.84; 'multiply': 0.84; 'divided': 0.93 |
| 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=o5q2pdoHvK5yJwPKwxomFpS9tqMOUAoj2xbDzlclGiw=; b=Orc5LREl2oPkdZCrNNCRdgobwP+kf472yDQtekpxJyX0vvsGkaRc5n0iJitY49+xos xg+Bbrk1AoTw04Q15AYixxwWBO9ZhD+WQNtfZGreMGdWMSNW3cyuqWcw0ig8IiwejGHU nFHqakl42bbGStZG8igBitDLZrq4ouBcwxuZ3xGM9qfb23W1g1WKyXr8NA6zLTn238P4 dQAy13cf8zmiS7ZsIiHZPDyPYJprYwKl+tiwiMq+Y84Js/edbtFvtiUDMOdbgYJslQSV I0qEMbRwEBxwChq+8pofxN3OtGPKnfsYKcOYsWf+eMG6wFDJdlNjHU73vzPVeD/8Rtb5 x/0A== |
| MIME-Version | 1.0 |
| X-Received | by 10.194.157.42 with SMTP id wj10mr3493480wjb.12.1361557636358; Fri, 22 Feb 2013 10:27:16 -0800 (PST) |
| In-Reply-To | <CAJ2vgs5oX0Oxt++K8v8qHdB46ewpoLKQ9QxQX5P3u_NvypFM7g@mail.gmail.com> |
| References | <CAJ2vgs5_gYPvMxfBUjs_6QgzUNd4akTvL2p0jV+7E-m8_6xeUw@mail.gmail.com> <CAO+9iGeOQ6jQPfNuG3TSSDK3vFGQVOuWPCgrOcMn+dtJZawj=Q@mail.gmail.com> <CAO+9iGc5bmp9iNveDQ7Bc_LcDDTX6o0rZdr8vHi1aNxYm6go5Q@mail.gmail.com> <CAJ2vgs76po_3JiuqGtLH3b=bP-U1TW-mYYtkxeU-bbx7Z2oHhw@mail.gmail.com> <CAJ2vgs4YvQ+RcKMjEnSimRE3pv3QYbuHuSeHfnU703w1QJr5Ew@mail.gmail.com> <CAJ2vgs5oX0Oxt++K8v8qHdB46ewpoLKQ9QxQX5P3u_NvypFM7g@mail.gmail.com> |
| Date | Fri, 22 Feb 2013 19:27:16 +0100 |
| Subject | Re: Number validation issue |
| From | Morten Engvoldsen <mortenengv@gmail.com> |
| To | Alec Taylor <alec.taylor6@gmail.com> |
| Content-Type | multipart/alternative; boundary=089e0112c51241adae04d6545765 |
| 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.2292.1361557644.2939.python-list@python.org> (permalink) |
| Lines | 117 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361557644 news.xs4all.nl 6845 [2001:888:2000:d::a6]:45296 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39603 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi,
Just to make it more clear: I am looking for how to generate the weight in :
1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7.. format for any
length of number instead of
weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1]
only for fixed digit.
My below code can check only for 9 digit, so if we provide a number of more
than 9 digit, it is not able to check that number. Hope, this makes clear
what i am looking for...
On Fri, Feb 22, 2013 at 6:27 PM, Morten Engvoldsen <mortenengv@gmail.com>wrote:
> Hi,
> My below code is wrong :
>
>
> elif mod == 11:
> >> if not len(checknum)!= 11:
> >> return False
> >> weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1]
> >> return (sum(w * int(x) for w, x in zip(weights, checknum)) %
> 11) ==0
>
> it works for 9 digit number , not 11 digit number, so i have changed the
> code and sending again with correct code with valid number:
>
> def is_valid_number(checknum):
> weights = [3, 2, 7, 6, 5, 4, 3, 2, 1]
>
> return (sum(w * int(x) for w, x in zip(weights, checknum)) % 11) == 0
>
> is_valid_number("123456785")
>
> This code validate this 9 digit number "123456785" with below algorithm:
>
>
> To verify the number use the following weights from right to left:
> 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7...
> Multiply each digit by its corresponding weight. Add the results together.
> For the number to be correct the
> total must be divisible by 11.
> Field with control digit 1 2 3 4 5 6 7 8 5
> Weight 3 2 7 6 5 4 3 2 1
> Produce +3 +4 +21 +24 +25 +24 +21 +16 +5 =143
> The sum must be divisible by 11 (143 divided by 11 leaves a remainder of
> 0).
>
> So i am looking for solution how i can change this code to validate with
> weight 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7... from
> right to left for any length of number. This code validate only 9 digit
> number.
>
> Sorry for inconvience :(
>
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Number validation issue Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-22 19:27 +0100
csiph-web