raw_input and break

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 4 16:54:36 EST 2015


On Wed, Nov 4, 2015 at 2:44 PM,  <input/ldompeling at 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.



More information about the Python-list mailing list