Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43207

Re: While loop help

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'true,': 0.05; 'matches': 0.07; 'subject:help': 0.08; 'string': 0.09; 'false,': 0.09; 'whatever.': 0.09; '12:57': 0.16; 'responses.': 0.16; 'wrote:': 0.18; 'programming': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'helpful': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'comparison': 0.31; 'responded': 0.31; "user's": 0.31; 'checking': 0.33; 'something': 0.35; 'no,': 0.35; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'email addr:gmail.com': 0.63; 'received:74.208': 0.68; 'saw': 0.77; 'received:74.208.4.194': 0.84; 'convenience,': 0.91
Date Tue, 09 Apr 2013 13:27:52 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: While loop help
References <b93147e7-9d17-4232-99a3-767b88f9e9ba@googlegroups.com> <596ca4b8-b5aa-4112-b086-6320108075f7@googlegroups.com> <mailman.348.1365516328.3114.python-list@python.org> <a530b25f-f9d9-45e9-925c-0ecd8a660cf6@googlegroups.com> <mailman.359.1365523839.3114.python-list@python.org> <1629a072-c512-439c-b751-c44f8e945c2e@googlegroups.com> <mailman.366.1365526028.3114.python-list@python.org> <fb27b1e2-6c94-45ae-ac3e-17a4595f4e97@googlegroups.com>
In-Reply-To <fb27b1e2-6c94-45ae-ac3e-17a4595f4e97@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:R8Gxbg2o1dG2+nGlt7NcmRb0FlFfxXNaeQK/apHSkJf hk92P4EDJmLxfMl21eUFw0zM8nP6DjKdv2rexsMgGkua5GvjC3 wDk4QTOLOeInRpVsDFMMo4wg2FP1m0S1O3QYgXKC7AUz+1aIt5 NoAn2gGNzvMugi4maGWL9mQfC6cmFMYuh5969+gaZt6CteZu2K Pl3gyqDI0cyA0Buj2xGv7XaIGAhHZc3ae60NoHt04efdsimK46 QFoctUSKdpxdvYLQC0ESnzxObIfI2MbpdJFgzg5RGLMDMFa0w9 YWtAMFaQbGiGrqvO2MEdXEh1exJQIf/TDwX1qinqQ7CwOyXgA= =
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.371.1365528500.3114.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365528500 news.xs4all.nl 2595 [2001:888:2000:d::a6]:42900
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43207

Show key headers only | View raw


On 04/09/2013 12:57 PM, thomasancilleri@gmail.com wrote:
> I responded before I saw this message, this was very helpful so I appreciate your quick and helpful responses. So do you think prompting for a string and then checking if the string is true is a good practice for something like this? When would checking for true/false be necessary?
>

No, DON'T check for the string to be true, check if it matches the 
requirements.  Word the question for the user's convenience, not the 
programming language's.  Don't ask for true and false, ask "Continue?" 
and accept "Y" or "N".  Or ask "Q for quit".  Or whatever.  Make your 
comparison case-insensitive, and permit one-character responses.

continue = "y"
while continue[:1].lower() == "y":
     do some work
     continue = raw_input("Do you want to continue (y/n)?"

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

While loop help thomasancilleri@gmail.com - 2013-04-09 06:32 -0700
  Re: While loop help thomasancilleri@gmail.com - 2013-04-09 06:57 -0700
    Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:12 -0400
      Re: While loop help thomasancilleri@gmail.com - 2013-04-09 10:18 -0700
        Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 03:23 +1000
        Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:30 -0400
  Re: While loop help thomasancilleri@gmail.com - 2013-04-09 06:58 -0700
    Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 00:05 +1000
      Re: While loop help thomasancilleri@gmail.com - 2013-04-09 08:47 -0700
        Re: While loop help Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-09 12:02 -0400
        Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:10 +1000
          Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:24 -0700
            Re: While loop help Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-09 12:36 -0400
            Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:47 +1000
              Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:57 -0700
                Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 03:08 +1000
                Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:27 -0400
              Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:57 -0700
          Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:24 -0700
          Re: While loop help Walter Hurry <walterhurry@lavabit.com> - 2013-04-09 19:35 +0000
            Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 16:12 -0400
              Re: While loop help Walter Hurry <walterhurry@lavabit.com> - 2013-04-09 20:59 +0000
                Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 08:36 +1000
        Re: While loop help rusi <rustompmody@gmail.com> - 2013-04-10 08:59 -0700
      Re: While loop help thomasancilleri@gmail.com - 2013-04-09 08:47 -0700
  Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 00:00 +1000
  Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:49 -0700
    Re: While loop help Larry Hudson <orgnut@yahoo.com> - 2013-04-09 23:44 -0700
      Re: While loop help Larry Hudson <orgnut@yahoo.com> - 2013-04-10 20:00 -0700
  Re: While loop help jmfauth <wxjmfauth@gmail.com> - 2013-04-09 12:19 -0700

csiph-web