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


Groups > comp.lang.python > #98245

Re: raw_input and break

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: raw_input and break
Date 2015-11-04 14:54 -0700
Message-ID <mailman.29.1446674118.16136.python-list@python.org> (permalink)
References <h%u_x.29450$bN3.2901@fx06.am1>

Show all headers | View raw


On Wed, Nov 4, 2015 at 2:44 PM,  <input/ldompeling@casema.nl> wrote:
> I have an continues loop with "while True:"
> Now I want to use "raw_input" and when I press "s" on the keybord that it will
> "break" the continues loop.
>
> I tried:
> choices = raw_input

This doesn't call raw_input. For that you need to write raw_input(),
where the parentheses indicate a function call. All the above does is
find the raw_input function and assign that function to the name
"choices".

> if choises == s:

Strings in Python are delimited with quotes: "s", not just s. The
latter is going to try to look up a variable named s, not denote a
string. Also, it's important to spell the variable here in the same
way that you did above. Above you have a c where here there is an s.
I'm assuming that this isn't exactly what you ran, because you most
likely would have gotten a NameError here. Please copy and paste
exactly the code that you're trying to run rather than retyping it.

> break

This needs to be indented. Not indenting it would be a SyntaxError, so
again I'm guessing that this isn't actually what you ran.

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


Thread

raw_input and break input/ldompeling@casema.nl - 2015-11-04 21:44 +0000
  Re: raw_input and break Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-04 14:54 -0700
  Re: raw_input and break Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-04 16:56 -0500
    Re: raw_input and break input/ldompeling@casema.nl - 2015-11-04 22:37 +0000
      Re: raw_input and break Steven D'Aprano <steve@pearwood.info> - 2015-11-05 11:44 +1100
  Re: raw_input and break tian.su.yale@gmail.com - 2015-11-04 21:39 -0800
    Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 09:22 +0000
      Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 11:01 +0100
        Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 10:40 +0000
          Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 12:38 +0100
            Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 12:59 +0000
              Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 15:16 +0100
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 14:34 +0000
                Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 18:06 +0100
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 17:28 +0000
                Re: raw_input and break Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-05 20:09 -0500
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-06 05:08 +0000
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-06 11:50 +0000
                Re: raw_input and break Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-06 08:25 -0500

csiph-web