While loop help

Chris Angelico rosuav at gmail.com
Tue Apr 9 10:05:25 EDT 2013


On Tue, Apr 9, 2013 at 11:58 PM,  <thomasancilleri at gmail.com> wrote:
> Also I'm getting a invalid syntax next to my elif statements that i wasnt getting before. why is this happening now?

Ah! That's relating to the close parenthesis problem I mentioned.
That's the exact issue I saw.

When you get told about a problem, sometimes the location pointed out
isn't the actual cause. What you have is a (near) guarantee that the
problem is no later in the file than that point; often it'll be on
that line or the one previous line. In this case, the code is
"raw_input(........ elif", which can't be properly parsed - the open
parenthesis is forcing the code to be interpreted as an expression,
and elif isn't an expression.

If you're stuck figuring out a problem, one neat trick is to delete
the line of code that's blamed for the problem and try again. If the
problem disappears, it was on that line; if the problem moves down to
the next line, it's probably on the preceding line. This trick doesn't
always work, but it can occasionally be quite handy.

ChrisA



More information about the Python-list mailing list