Wednesday, March 30, 2016

Python Indentation Error

I've only been using Python for a year.

Before that, my focuses were Java and Perl.

An interesting error I came across, since Python has stricter criteria for formatting was: "IndentationError: expected an indented block"

The code in question:

The error might be considered a red herring since the problem with the else: statement was that there was no real code to run after the if statement.

Once I added a logging statement:

The error went away.