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


Groups > comp.lang.python > #52277

Re: beginner question (True False help)

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'true,': 0.05; '*not*': 0.07; 'subject:help': 0.08; 'string': 0.09; "'a'": 0.09; 'complicate': 0.09; 'enabled.': 0.09; 'newline': 0.09; 'trailing': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '"while"': 0.16; "'n'": 0.16; 'be:': 0.16; 'eof': 0.16; 'given,': 0.16; 'hits': 0.16; 'loop.': 0.16; 'looping.': 0.16; 'subject:beginner': 0.16; 'true:': 0.16; 'unix,': 0.16; 'windows:': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'module': 0.19; 'things.': 0.19; '>>>': 0.22; 'input': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'letter.': 0.31; 'yes.': 0.31; 'this.': 0.32; 'subject: (': 0.35; 'advice': 0.35; 'something': 0.35; 'test': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'should': 0.36; 'step': 0.37; 'does': 0.39; 'read': 0.60; 'letters': 0.60; 'august': 0.61; 'break': 0.61; 'you.': 0.62; "you've": 0.63; 'our': 0.64; 'more': 0.64; 'prompt': 0.68; 'again?': 0.84; 'stripped.': 0.84; 'top.': 0.84; 'forever.': 0.91; 'subject:True': 0.91; 'to:addr:comcast.net': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=SN4mazqUNG+u6VrbHTWopUwv0YZNynx/ImfUjxos718=; b=D4QVieQntvM//hvbE+FY8EYr0Mr/A2EG+62gPsVtvzqnSl6nVAqlzE+lZXg/l7nRqX tSncBVT9tO/KMrkrSyggOSci6QZrsxFLs9fTrKHi5khce/MpuYs6mEoxeH9x9B4317Gb d7Jrdbxzyxz7jwTX+mz6tHvGVHOcl8uJ62O8ZCgEj/wGeJlZWAoBYuKosVArhoIdY1iw ODEzT06TX9qIQBD9OkawrHmmeeGvHcPoGJHCp8mkwyJUcaRYUpJ6lL6CkiCZWT92ajth 1jFIp0PN2LcwVOooZvfyBDW0TB/S5W+8THgtjGxA8tcHBDYBekUGBeVKM3tgKTLdkDkC FIew==
X-Received by 10.112.34.178 with SMTP id a18mr1054396lbj.67.1376089557533; Fri, 09 Aug 2013 16:05:57 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <b9e1881e-dd26-497f-83d0-8884d08ec8ff@googlegroups.com>
References <6c6dedec-5e47-4229-bc67-01b058cdb410@googlegroups.com> <b9e1881e-dd26-497f-83d0-8884d08ec8ff@googlegroups.com>
From Joshua Landau <joshua@landau.ws>
Date Sat, 10 Aug 2013 00:05:17 +0100
X-Google-Sender-Auth Nqs6Zvk1WnFJbf3Xo7g3SPsexLU
Subject Re: beginner question (True False help)
To kurt schwitters <eschneider92@comcast.net>
Content-Type text/plain; charset=UTF-8
Cc python-list <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.410.1376089560.1251.python-list@python.org> (permalink)
Lines 69
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376089560 news.xs4all.nl 15869 [2001:888:2000:d::a6]:36020
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52277

Show key headers only | View raw


On 9 August 2013 23:27,  <eschneider92@comcast.net> wrote:
> This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities?

...

Yes.

You didn't listen to any of the advice we've been giving you. You've
had *much* better answers given than this.


Start from the top.

We need letters, so define that:

    letters = "abcdefghijkl"

We then want to loop, possibly forever. A good choice is a "while" loop.

    # True is always True, so will loop forever
    while True:

We then want to ask for a letter. We want to use "input". Write
"help(input)" in the Python Shell and you get

    >>> help(input)
    Help on built-in function input in module builtins:

    input(...)
        input([prompt]) -> string

        Read a string from standard input.  The trailing newline is stripped.
        If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return),
raise EOFError.
        On Unix, GNU readline is used if enabled.  The prompt string, if given,
        is printed without a trailing newline before reading.

So our line should be:

    letter = input("Type a letter from 'a' to 'n' in the alphabet: ")

Then we want to test if it's on of our letters:

    if letter in letters:

And if so we want to say something positive:

        print("That's right.")

If not we want to say something negative:

    else:
        print("That's wrong.")

And then we want to ask if we should go again:

    go_again = input("Do you want to do this again? ")

If the response is "y" or "yes", we want to continue looping. The
while loop will do that automatically, so we can do nothing in this
circumstance.

If the response in *not* "y" or "yes", we want to stop:

    if go_again not in ("y", "yes"):
       break


That's it. No need to complicate things. Just take it one step at a time.

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


Thread

beginner question (True False help) eschneider92@comcast.net - 2013-08-07 01:17 -0700
  Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-07 09:42 +0100
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-07 13:59 -0700
    Re: beginner question (True False help) Dave Angel <davea@davea.name> - 2013-08-08 01:18 +0000
  Re: beginner question (True False help) Larry Hudson <orgnut@yahoo.com> - 2013-08-07 19:49 -0700
  Re: beginner question (True False help) wxjmfauth@gmail.com - 2013-08-07 23:20 -0700
    Re: beginner question (True False help) Chris Angelico <rosuav@gmail.com> - 2013-08-08 12:41 +0100
    Re: beginner question (True False help) Terry Reedy <tjreedy@udel.edu> - 2013-08-08 16:29 -0400
      Re: beginner question (True False help) wxjmfauth@gmail.com - 2013-08-09 01:05 -0700
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 15:27 -0700
    Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 00:05 +0100
    Re: beginner question (True False help) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-09 22:58 -0400
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 15:28 -0700
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:14 -0700
    Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 00:30 +0100
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:24 -0700
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:34 -0700
    Re: beginner question (True False help) Joshua Landau <joshua@landau.ws> - 2013-08-10 02:22 +0100
    Re: beginner question (True False help) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-10 01:40 +0000
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:40 -0700
    Re: beginner question (True False help) MRAB <python@mrabarnett.plus.com> - 2013-08-10 01:39 +0100
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 16:43 -0700
  Re: beginner question (True False help) eschneider92@comcast.net - 2013-08-09 18:08 -0700

csiph-web