Loading section...
The if Statement
Concepts: pyIfElse
Basic if Syntax Both indented print statements run because age is 21, which is greater than or equal to 18. The final print statement runs regardless of the condition because it is not indented under the if. When Conditions Are False When the condition evaluates to False, Python skips the entire indented block and continues with the next unindented line: Since 15 is not greater than 30, the condition is False and both indented lines are skipped. Only the final unindented line executes. Conditions and Booleans Each comparison operator serves a different purpose. Here is a quick reference for the six operators you will use most often in conditional logic: Collection Conditions Conditions work with any data type, not just numbers. You can compare strings, check membership in collections, and