IndentationError

An IndentationError occurs most frequently when indenting code with a mixture of spaces or tabs. It is preferred to indent your code with four spaces rather than a tab character. You can check for tabs and spaces in most text editors by showing all symbols or run the -tt flag with Python to identify troublesome lines (that is, if you're script doesn't report the exception in the first place). Once you select an editor of your liking, be sure to configure it to uniformly place spacing throughout your script.

Another common source of this error is failing to match the appropriate indentation level within your script. For example, in lengthier code segments you might mistakenly indent some line of code with too few spaces or tabs: ...

Get Learning Python for Forensics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.