Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98294
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: raw_input and break |
| Date | 2015-11-05 11:01 +0100 |
| Organization | None |
| Message-ID | <mailman.50.1446717724.16136.python-list@python.org> (permalink) |
| References | <4270fade-5f09-4935-a99a-f2be344202b2@googlegroups.com> <adF_x.29624$Xj7.21693@fe35.am1> |
input/ldompeling@casema.nl wrote:
> while True:
> enable_servo()
> servo(90)
> mindist = 80
> choices = input("letter s to stop:")
> if choices == 's':
> print ("stop")
> break
> if mindist > us_dist(15):
> bwd()
> print ("backward 1x")
> In this script it always break even when I not press 's'
> I want that this script go's to if mindist > us_dist(15):
> And when I press 's' its stop.
>
> Any ideas ?
Does it print something like
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
when it stops? This is called a "traceback" and you should always include it
in your post when you need help with an error in your script.
In this particular case the problem is that you are using Python 2 where
input() tries to execute the text the user enters as Python code.
Tian's example code assumes Python 3.
To fix your problem replace the line
choices = input("letter s to stop:")
in your script with
choices = raw_input("letter s to stop:")
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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