Inconsistent whitespace error

Jan 7, 2013 at 12:40 PM

I copy-pasted a code from the web to my project, and get an inconsistent whitespace error. I tried to fix this error with no success. 

this is the code:

for u in units[s]:

      dplaces = [s for s in u if d in values[s]]

      if len(dplaces) == 0:

          return False ## Contradiction: no place for this value

      elif len(dplaces) == 1:          

            if not assign(values,dplaces[0],d):

                return False

            # d can only be in one place in unit; assign it there

            if not assign(values, dplaces[0], d):

               return False

    return values

I get the error at the "if not assign(values,dplaces[0],d):" line.

if i stand at the end of the elif line above it and press enter, 

the marker seems to be at the right place, starting a new block. if i enter a new command, it get the "inconsistent whitespace" error instead of the

of the "if not assign(values,dplaces[0],d):" line. I checked all carriage return and whitespaces at notepad editor, it all looks consistent in all code.

why is this happening??

 

Help will be highly appreciated...!

 

Coordinator
Jan 9, 2013 at 5:19 PM

One thing I notice is your last two "return False" statements have different levels of indentation.  The 1st one is indented 4 spaces deep from the if not assign, and the 2nd is indented 3 spaces deep.

Also, hopefully this is being reported as a warning by default, but you can control the behavior from Tools->Options->Python Tools->Advanced using the "Report inconsistent indentation as" option.