help needed to understand an error message.

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Mar 26 09:26:24 EDT 2012


Aloke Ghosh wrote:
> Hi,
> I am learning Python and do not have programming experience.
> I was following 
> an exercise from http://learnpythonthehardway.org/book/ex2.html
> and made a mistake in entry :
>
> *Print"I like typing this."* 
>
> and got the following error message:
>
> *In [2]: Print"I like typing this."*
> *------------------------------------------------------------*
> *   File "<ipython console>", line 1*
> *     Print"I like typing this."*
> *                                        ^*
> *SyntaxError: invalid syntax*
>
> I feel the error is in Capital P in print .
> However the error indicated with "*^*" 
> hints at quote at the end of the line.
>
> *Can any one please help me understand this.*
>
> -- 
> A.K.Ghosh
Why don't you just try with a lowercase p ?

The correct syntax would be

print "I like typing this"

or in Python 3:

print ("I like typing this")

Anyway, the hint indicates the last quote because this is the location 
where the python interpreter realizes it won't be able to execute the 
code. You should not worry about that too much.

JM



More information about the Python-list mailing list