top-level loops

Michael Chermside mcherm at mcherm.com
Wed Oct 8 17:32:52 EDT 2003


Stefan writes:
> I am writing a program (code included) and I would like to comment out
> the two top-level loops and run the code that is under it regularly,
> however, because the following code is not indented properly the
> interpreter chokes. Is there a way around this?

Well first of all, I prefer to use an editor which will allow me
to indent or dedent entire blocks of code at a time. There are lots
of others, but Idle (which almost certainly came with your copy of
Python) is one... select the block then use tab or shift-tab.

Also, in your case there's another quick work-around:


    #for i in range(0,3):
    #    for j in range(0,3):
    for i in range(0,1):
        for j in range(0,1):

        ... rest of program goes here...


Notice how I left in the for loops, but made sure that each
occurred only once.

-- Michael Chermside






More information about the Python-list mailing list