if 6 < hour < 20:
needs to be
if (6 < hour) and (hour < 20):
No complex inequalities without an
or statement. What was happening is it evaluated
6 < hour which resolved to either
false then it tried to evaluate
true < 20 which just doesn't make sense.