[Tutor] need help tracing a syntax error

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sat Mar 11 21:30:47 CET 2006


> I get the message
>
> syntax error
>
>
> and it highlights    r2
>
> in the line
>
> .If r2 == 1:

Hi Kermit,

Next time, rather than describe the error message here in paraphrase,
please copy-and-paste it in.  Your paraphrase of the situation here hides
useful information.  We would rather that you give it to us straight and
unfiltered.  (Gosh, I sound like I'm in a bar or something.  *grin*)

I can see a problem, but I'm not sure if it's the only one.  Keywords are
case sensitive.  'If' is different than 'if'.  You're using 'If', which is
not a keyword, so what Python is seeing is essentially:

     some_variable_name another_variable_name

which is illegal syntax in Python.

Python can't tell that 'If' is meant to be the keyword 'if', so the
closest it can say is that something weird happened as it was reading up
to 'r2', so that's why the syntax error arrow is pointing at r2 rather
than the 'If'.



More information about the Tutor mailing list