Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail 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; 'subject:error': 0.03; 'else:': 0.03; 'subject:Python': 0.06; 'wednesday,': 0.07; 'string': 0.09; 'function,': 0.09; 'parsing': 0.09; 'raises': 0.09; 'snippet': 0.09; 'try:': 0.09; 'useless': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'question.': 0.14; "'input'": 0.16; '32,': 0.16; 'eof': 0.16; 'exited': 0.16; 'nameerror:': 0.16; 'pressed': 0.16; 'reproduce': 0.16; 'scope,': 0.16; 'script,': 0.16; 'sees': 0.16; 'string)': 0.16; 'subject: \n ': 0.16; 'subject:program': 0.16; 'syntaxerror:': 0.16; 'sys.exit(0)': 0.16; 'unexpected': 0.16; 'used:': 0.16; 'using,': 0.16; 'sender:addr:gmail.com': 0.17; 'fix': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'version.': 0.19; '(the': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'replace': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; 'equivalent': 0.26; 'first,': 0.26; 'pass': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'towards': 0.31; '"",': 0.31; '"please': 0.31; 'complete,': 0.31; 'factor': 0.31; 'second,': 0.31; 'file': 0.32; 'probably': 0.32; 'running': 0.33; '(most': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'except': 0.35; 'problem.': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'shows': 0.36; 'error.': 0.37; 'step': 0.37; 'thank': 0.38; 'problems': 0.38; 'version,': 0.38; 'skip:- 10': 0.38; 'rather': 0.38; 'anything': 0.39; 'recent': 0.39; 'though,': 0.39; 'how': 0.40; 'middle': 0.60; 'hope': 0.61; 'issues,': 0.61; 'simple': 0.61; "you're": 0.61; 'complete': 0.62; 'such': 0.63; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'yes': 0.68; 'press': 0.70; 'computers': 0.72; 'evaluate': 0.72; 'us,': 0.73; 'subject:get': 0.81; '2.7.': 0.84; 'believe,': 0.84; 'loose': 0.84; 'serious': 0.97; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=TSb710zDh2BS7rhXZdJwmU8OoDzBVfEpBni4FQ0KKTQ=; b=mnDucgJIWsAz0N4FPVD8jAwuXceMxqOCZd3tm4qv1QhuKp2ODe+itJwtxQsUS/6NhY LfPx5t091KkwJCfn5cAjVpYj2HwFdTSlNA2fRLbOuozCq4lq/tg436u4siQ+t1pTPvuh +8s848NP8hkxCydEyxY3tijuf4sbx5XEQ4++wPBOMk5cJmf2UhZq0LFrgfhqmU5vQR+b qQxy9bUxf7r4KsqdZO+h0P5X3o1WqyBGboupxr1YT6gW/RddcwKqpWQs2/WlfD9xqyNj JotL51dnX/ReNOGfSfzA90WWcAZ4kl2jkhQ2GKujGWquJYaX5IqsGMFTCcUk5TyYIOgE 8XFA== X-Received: by 10.205.68.195 with SMTP id xz3mr10003615bkb.41.1370446732198; Wed, 05 Jun 2013 08:38:52 -0700 (PDT) MIME-Version: 1.0 Sender: zachary.ware@gmail.com In-Reply-To: <5d967bc8-2ae4-4844-8e20-631364f75037@googlegroups.com> References: <498fb115-8568-478d-8443-1be20dd5c335@googlegroups.com> <5d967bc8-2ae4-4844-8e20-631364f75037@googlegroups.com> From: Zachary Ware Date: Wed, 5 Jun 2013 10:38:32 -0500 X-Google-Sender-Auth: 1w71xQ_q3rZtZM5cdHyDqTksabU Subject: Re: I just wrote my first Python program a guessing game and it exits with an error I get this. To: Armando Montes De Oca Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 81 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370446738 news.xs4all.nl 15909 [2001:888:2000:d::a6]:48450 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47097 On Wed, Jun 5, 2013 at 10:14 AM, Armando Montes De Oca wrote: > On Wednesday, June 5, 2013 10:40:52 AM UTC-4, Armando Montes De Oca wrote: >> Traceback (most recent call last): >> >> File "Guessing_Game.py", line 32, in >> >> input (enter) >> >> File "", line 0 >> >> ^ >> >> SyntaxError: unexpected EOF while parsing >> >> ------------------ >> >> (program exited with code: 1) >> >> This is the only place a string is used: >> >> else: >> >> print "Sorry you loose the game." >> >> computernum = str(computernum) >> >> print " The computers number was!"+ computernum >> >> input (enter) >> >> sys.exit(0) >> Yes I did declare and enter value it is: > enter = "Please Press Enter To Continue..." >> Thank You, Hi Armando, There are a few problems with your question. To be able to help you, we really need to know your Python version, what OS you are using, how you are running your script, and at what point you get the error in question. Also, just a snippet of code from the middle of the script is useless to us, we need to see a complete, runnable program that shows your problem. In this particular case, though, I can deduce a few things and, I believe, answer your question. First, your Python version. Judging by your use of 'print' as a statement rather than a function, it looks like you're using Python 2, probably 2.7. This is a big factor in your problem. Second, when you get your error. I'm betting it's after you see "Please Press Enter To Continue..." and have pressed 'enter'. Now the kicker: I can reproduce your problem with the following complete program: # error_test.py input('Press enter') # end of error_test.py The problem here is that you are using 'input()' in Python 2. In Python 2, 'input()' is equivalent to 'eval(raw_input())', which means that anything you give to 'input' will be evaluated in the current scope, and this is a HUGE security hole. It can also cause serious issues, such as you are having with your program: when you press enter at the prompt, you pass '' (the empty string) to eval, which sees EOF before it can actually evaluate anything, and so it raises a SyntaxError. The simple fix here is to replace every occurance of 'input(' with 'raw_input(', or to make a step towards Python 3 compatibility, add this to the top of your program: try: input = raw_input except NameError: pass Hope this helps, Zach