Chapter 9: Incremental development

pass

face Josiah Wang

I mentioned a point earlier that your code should always work.

Ideally, you should not have any syntax errors at any point when you run your program, even if you are only halfway through completing your program.

With compound statements like if (and while), you will need to write more than just the condition. Sometimes you do not immediately want to implement the bits inside a block, but just want to outline the high level logic first. For example,

if x == 5:

else:

Of course, this will cause a syntax error as Python needs a block of indented code inside each of your if and else clause.

Here, you can use the pass keyword as a placeholder.

if x == 5:
    pass
else:
    pass

pass is a simple statement, and it basically means “do nothing”.

Now, your code works without any syntax errors.

Then you can implement the different blocks in your own time.