Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: raw_input and break Date: Thu, 05 Nov 2015 11:01:45 +0100 Organization: None Lines: 46 Message-ID: References: <4270fade-5f09-4935-a99a-f2be344202b2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de XR2lUORkVLP90oPyBipm+ADReee2WtQSauyUEuLWn4GA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'tries': 0.05; 'eof': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unexpected': 0.09; 'python': 0.10; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:break': 0.16; 'syntaxerror:': 0.16; 'true:': 0.16; 'wrote:': 0.16; 'script.': 0.18; 'fix': 0.21; '"",': 0.22; 'assumes': 0.22; 'parsing': 0.22; 'code.': 0.23; '(most': 0.24; 'script': 0.25; 'header:User- Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'error': 0.27; 'print': 0.30; 'code': 0.30; 'post': 0.31; 'problem': 0.33; 'choices': 0.33; 'traceback': 0.33; 'file': 0.34; 'text': 0.35; 'replace': 0.35; 'something': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'called': 0.40; 'your': 0.60; 'press': 0.61 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd897d.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98294 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 "", line 1, in File "", 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:")