Re: Problem with the "for" loop syntax
On 20Jun2013 11:09, Chris Angelico <email@example.com> wrote:
| On Thu, Jun 20, 2013 at 11:02 AM, Arturo B <firstname.lastname@example.org> wrote:
| > Fixed, the problem was in
| > HANGMANPICS
| > I didn't open the brackets.
| > Thank you guys :)
| General debugging tip: Syntax errors are sometimes discovered quite
| some way below the actual cause. The easiest way to figure out what's
| the real cause is to start cutting away unnecessary code until all
| that's left is the tiniest part that still has the error. This is also
| very helpful as a prerequisite to posting on a list like this, so even
| if you can't find the problem yourself by this method (you often will,
| though), it's well worth doing.
Also, opening-and-not-closing a set of brackets is almost the only
way in Python to make this kind of error (syntax at one line, actual
mistake far before).
See if your editor has a show-the-matching-bracket mode.
I use vi/vim and it both shows the matching bracket when the cursor
is on one and also have a keystroke to bounce the curser between
this bracket and the matching one.
If you suspect you failed to close a bracket, one approach is to
go _below_ the syntax error (or right on it) and type a closing
bracket. Then see where the editor thinks the opening one is.
If you have a syntax highlighting editor (highlights keywords,
colours quoted text differently, etc) it can also be useful for
finding errors; the text will be the wrong colour at some point.
Just a few suggestions to aid finding this kind of thing without
Cameron Simpson <email@example.com>
Are you experiencing more Windows95 crashes than the norm? How on earth
would you _know_? - John Brook <firstname.lastname@example.org>
reporting about a new virus
|All times are GMT. The time now is 02:28 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.