[Tutor] Problem with running Python

Alan Gauld alan.gauld at btinternet.com
Fri Apr 22 20:04:34 CEST 2011


"Alex Butler" <ambutler at bowdoin.edu> wrote

> I am new to programming on Python and am teaching myself.  I have 
> figured
> out some basics of coding, however whenever I try to run the program 
> or
> check its functionality (Alt + X on my windows) it always comes back 
> saying
> that "there's an error in your program: invalid syntax."  However, 
> when it
> returns to the IDLE page and highlights the error, it highlights the 
> 7 in
> the python 2.7.1 above any coding.  And if I am able to delete that 
> text, it
> then links the syntax error to the multiple '>' in the code.  Is 
> this a
> common issue with a simple fix?  Thanks

It sounds like you may be trying to execute the code in the shell 
window.
This won't work because of all the stuff that the interpreter prints.
Thus in the interactive prompt you see:

>>> print( "hello world")

But in your program file you only type:

print( "hello world" )

The >>> bit is part of the interpreter not the program.

>From your comments thats the best that I can guess.
If thats not the problem then we will neeed more detail about what
exactly you are doing and the specific error messages you get
printed.

You might find Danny Yoo's introduction to IDLE useful for
a visual reference.

http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html

Its for Python 2.4 but the principles of using it for later versions
are exactly the same.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list