Newbie: unexpected indenting error

Martin S shieldfire at gmail.com
Sun Jul 13 05:03:30 EDT 2014


Thanks, the problem was apparently a mix of way to indent the code.
It's confused the H out of the editor. Using standard indentation
solved the error.

2014-07-13 9:28 GMT+02:00 Gary Herron <gherron at digipen.edu>:
> On 07/13/2014 12:01 AM, Martin S wrote:
>>
>> While coding a rating calculator I am using a for-loop within
>> if-elif-else.
>> When using the for-loop in the first if instance my editor accepts
>> this, but when using the same for-loop within the elif instance it
>> complain about "unexpected indent".
>>
>> Like so:
>>
>> def function(x):
>>     if rdiff >=500:
>>        for ....
>>           [do stuff]
>>     elif rdiff >=410:
>>         for ...                      <== unexpected indent
>>            [do other stuff]
>>
>>
>> What the...? What am I doing wrong?
>> (hopefully the indents translate; else def, if/elif, for and [dostuff]
>> are indented)
>>
>> /Martin S
>
>
> The code looks OK, but looks can be deceiving if you've manage to mix tabs
> and spaces to achieve that.
>
> Check for a mixture, and settle on one.  Tabs would work, but the
> recommendation is to use spaces.
>
> If you don't have a mixture of the two, then we have a mystery. Send your
> file as an attachment, and we'll take a closer look at it.
>
> Gary Herron
>
>
>
> --
> Dr. Gary Herron
> Department of Computer Science
> DigiPen Institute of Technology
> (425) 895-4418
>



-- 
Regards,

Martin S



More information about the Python-list mailing list