Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59584
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; 'jan': 0.12; '9:15': 0.16; 'differs': 0.16; 'fine.': 0.16; 'len(res)': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'res': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'header :User-Agent:1': 0.23; 'least': 0.26; 'code:': 0.26; 'asking': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'piece': 0.31; 'problem': 0.35; 'hundreds': 0.35; 'two': 0.37; 'checks': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'hope': 0.61; 'received:173': 0.61; 'simple': 0.61; 'first': 0.61; 'received:fios.verizon.net': 0.84; 'try,': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Bug asking for input number |
| Date | Fri, 15 Nov 2013 21:37:41 -0500 |
| References | <94e9901a-82e4-43a4-81e1-c2a0f8e96fc8@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-59-117-133.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
| In-Reply-To | <94e9901a-82e4-43a4-81e1-c2a0f8e96fc8@googlegroups.com> |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2697.1384569481.18130.python-list@python.org> (permalink) |
| Lines | 31 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1384569481 news.xs4all.nl 15898 [2001:888:2000:d::a6]:51395 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:59584 |
Show key headers only | View raw
On 11/15/2013 9:15 PM, Arturo B wrote:
> Hi! I hope you can help me.
>
> I'm writting a simple piece of code.
> I need to keep asking for a number until it has all this specifications:
>
> - It is a number
> - It's lenght is 3
> - The hundred's digit differs from the one's digit by at least two
>
> My problem is that I enter a valid number like: 123, 321, 159, 346... and it keeps asking for a valid number.
If you enter a 'valid' number at first try, it works fine.
> Here's mi code:
>
> res = input('Give me a number --> ')
> hundreds = int(res[0])
> ones = int(res[2])
>
> # checks if the user enters a valid number
> while not res.isdigit() or not len(res) == 3 or abs(hundreds - ones) <= 2:
Look at that last condition *carefully*!!!!
> res = input('Enter a valid number --> ')
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bug asking for input number Arturo B <a7xrturodev@gmail.com> - 2013-11-15 18:15 -0800 Re: Bug asking for input number MRAB <python@mrabarnett.plus.com> - 2013-11-16 02:33 +0000 Re: Bug asking for input number Terry Reedy <tjreedy@udel.edu> - 2013-11-15 21:37 -0500 Re: Bug asking for input number Arturo B <a7xrturodev@gmail.com> - 2013-11-15 19:03 -0800 Re: Bug asking for input number Christopher Welborn <cjwelborn@live.com> - 2013-11-15 21:15 -0600 Re: Bug asking for input number Christopher Welborn <cjwelborn@live.com> - 2013-11-15 20:47 -0600
csiph-web