8.1. if statement

The if statement for Python will seem amazingly familiar; it is made up of three main components: the keyword itself, an expression which is tested for its truth value, and a code suite to execute if the expression evaluates to non-zero or true. The syntax for an if statement:

						if
						expression:
						expr_true_suite
					

The suite of the if clause, expr_true_suite, will be executed only if the above conditional expression results in a Boolean true value. Otherwise, execution resumes at the next statement following the suite.

8.1.1. Multiple Conditional Expressions

The Boolean operators and, or, and not can be used to provide multiple conditional expressions or perform negation of expressions in the same if statement.

							if not warn and ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.