[Tutor] Python trouble

Steven D'Aprano steve at pearwood.info
Sat Apr 23 02:03:12 CEST 2011


Alex Butler wrote:
> Ok let me try to be more clear.  I am trying to write code in the IDLE
> Python GUI of python 2.7.  When I open the new python shell, there is a
> written header as well as the three >s on the left side.  I now those are
> used as indents and I do not type them in.  However, whenever I write any
> type of code and either attempt to run or click alt + x to check module, it
> says "there is an error in your program: invalid syntax."  Then when it goes
> back to the page to highlight the syntax error the second > is highlighted
> in color as it is the problem.  Before I deleted the header from this
> program, it would highlight the 7 after the 2. In the header.

The >>> is called the prompt. It is not part of the code, it is just 
there to prompt you that the interpreter is waiting for you. If you 
start a command that goes over two or more lines, the prompt will change 
to three dots ... to remind you that you haven't finished writing the 
command yet.

Please COPY and PASTE an example of the system error. Do not retype it, 
especially not from memory, but actually copy and paste the complete 
error, including the line it claims is invalid, and paste it into a 
reply. Like this:


 >>> x = 1
 >>> y = 2
 >>> if x=y:
   File "<stdin>", line 1
     if x=y:
         ^
SyntaxError: invalid syntax




Thank you.




-- 
Steven


More information about the Tutor mailing list