[Tutor] indent error on if/elif/else

Tim Golden mail at timgolden.me.uk
Thu Sep 10 17:41:42 CEST 2015


On 10/09/2015 16:38, richard kappler wrote:
> Here's my code, no tabs were used, all whitespace verified made with
> spacebar:
> 
> print("Please enter a number for feed speed...")
> print("1 - Batch")
> print("2 - 2 per second")
> print("3 - Real Time")
> print("4 - Exit")
> 
> if x == ord('1'):
>     delay = 0
> elif x == ord('2'):
>     delay = 0.5
> elif x == ord('3'):
>     # set delay real time
>     # read timestamp from line, create an offset
>     # send lin iaw server time with offset
> else:
>     print("bad choice, exiting")
>     os.exit()
> 
> #################
> 
> Here's the Traceback:
> 
>   File "dataFeedTest.py", line 44
>     else:
>        ^
> IndentationError: expected an indented block
> 
> 
> Not a clue why it's doing this. Any help?

Because the comments don't qualify as a statement. You need to have at
least a "pass" in there.

TJG



More information about the Tutor mailing list