raw_input and break
input/ldompeling at casema.nl
input/ldompeling at casema.nl
Thu Nov 5 05:40:23 EST 2015
In reply to "Peter Otten" who wrote the following:
> input/ldompeling at 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):
>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:")
Oh no, this is not what I want. Now it is waiting for input when its go further with the script.
Because I have an while True: so I want that the script go's continue only when I press a key then it must stop the script.
Thanks
--------------------------------------------------------------------------------------------------------------------------
> > 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:")
--
--------------------------------- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
More information about the Python-list
mailing list