Why does my compiler say invalid syntax then highlight...?

Duncan Booth duncan.booth at invalid.invalid
Tue Mar 11 04:36:29 EDT 2008


Mensanator <mensanator at aol.com> wrote:

> On Mar 10, 10:44‹¨«pm, Nathan Pinno <MadComputer... at gmail.com> wrote:
>> Why does my compiler say invalid syntax and then highlight the
>> quotation marks in the following code:
>>
>> # This program is to find primes.
> 
> Needs work.

Be fair. The OP hadn't managed to figure out why the program wasn't 
running, so you can't expect him to have got all the bugs out of the code 
yet. And he only asked about the specific syntax error not the entire 
solution to his homework.

My advice to Nathan would be:

1. If you get a weird syntax error that you don't understand try cutting 
the code down to just the bit which generates the error.

2. Play around in the interactive interpreter to see what works and what 
doesn't.

3. If you don't understand why the code doesn't work then get a stuffed 
toy, cardboard cutout of a person, or the least technical member of your 
family and explain to them in great detail exactly why the code must 
(despite error messages to the contrary) be correct. Usually you'll spot 
the problem half way through the explanation.

4. If you post to this list then post the full error message and traceback. 
That way we don't have to guess which quotation marks are the problem.



More information about the Python-list mailing list