IndentationError
Peter Pearson
ppearson at nowhere.invalid
Thu Dec 10 22:59:36 EST 2009
On Fri, 11 Dec 2009 12:57:15 +1100, Lie Ryan <lie.1296 at gmail.com> wrote:
> On 12/10/2009 6:32 AM, hong zhang wrote:
>> List,
>>
>> I got error says IndentationError in end of line.
>> I could not figure out why. See following:
>>
>> $ ./cont-mcs
>> File "./cont-mcs", line 264
>> mcs1 = ht_val+cck_val+green_val+fat_val+sgi_val
>> ^
>> IndentationError: unindent does not match any outer indentation level
>>
>
> Look at the surrounding code. Indentation Errors often lies on the
> previous few lines. Possibly caused by unmatching parentheses.
Do you see what's wrong here? ...
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> if None:
... print x
... print y
File "<stdin>", line 3
print y
^
IndentationError: unindent does not match any outer indentation level
>>>
The problem is that "print y" is indented less than "print x",
meaning that the indented code block containing "print x" is over,
and yet "print y" is *not* indented the same as the "if".
--
To email me, substitute nowhere->spamcop, invalid->net.
More information about the Python-list
mailing list