Nick Nick - 5 months ago 60
Python Question

How to debug indentation errors in python

I am trying to write my very first python script. This was working but then after some slight refactoring I have, apparently, broken the indentation. I can not determine what is the problem. The interpretor complains about the following method. Can someone point it out?

def dataReceived(self, data):
a = data.split(':')
print a
if len(a) > 1:
command = a[0]
content = a[1]

msg = ""
if command == "iam": = content
msg = + " has joined"

elif command == "msg":
msg = + ": " + content
print msg

The error reads: File "", line 17
a = data.split(':')
^ IndentationError: expected an indented block


You start using a text editor that allows you to show indents, and you become consistent about using spaces instead of tabs, and you enforce that in your editor.