I just wrote my first Python program a guessing game and it exits with an error I get this.

Tim Golden mail at timgolden.me.uk
Wed Jun 5 11:23:36 EDT 2013


On 05/06/2013 16:14, 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 <module>
>>
>>     input (enter)
>>
>>   File "<string>", line 0
>>
>>     ^
>>
>> SyntaxError: unexpected EOF while parsing


Armando. Try this at a Python prompt, and just press Enter without
entering any text.

  input("Please enter something:")


The trouble is that the beguilingly-named "input" function actually
*evaluates* what you type, ie it's the same as doing this:

  eval("")

which, as you can see, gives the same error message. You're clearly
using Python 2.x as your prints are statements, so input has this
characteristic. Instead you should use raw_input:

  raw_input(enter)

TJG



More information about the Python-list mailing list