The if statement
Learn how if statements work in Python
We'll cover the following...
Python’s if statement is pretty easy to use. Let’s spend a few minutes looking at some examples to better acquaint ourselves with this construct.
Press + to interact
if 2 > 1:print("This is a True statement!")#This is a True Statement!
This conditional tests the “truthfulness” of the following statement: 2 > 1. Since this statement evaluates to True, it will cause the last line in the example to print to the screen or standard out (stdout).
Python Cares About Space
The Python language cares a lot about space. You will notice that in our conditional ...