Linux/Unix > Python Essential Reference, Second Edition > 5. Control Flow > Conditionals | See All Titles

< BACK | Make Note | Bookmark | CONTINUE >

155117184014003188065099048180054212144238241179195140058238110137104031089147127048229091

### Conditionals

The `if`, `else`, and `elif` statements control conditional code execution. The general format of a conditional statement is as follows:

    if expression:
        statements
    elif expression:
        statements
    elif expression:

        statements
    ...
    else:
        statements

If no action is to be taken, you can omit both the `else` and `elif` clauses of a conditional. Use the `pass` statement if no statements exist for a particular clause:

    if expression:
        pass            # Do nothing
    else:
        statements

| Last updated on 3/28/2002 Python Essential Reference, Second Edition, © 2002 New Riders Publishing

< BACK | Make Note | Bookmark | CONTINUE >

© 2002, O'Reilly & Associates, Inc.