We use an if statement to write code that adapts to different situations. We recognize it by the keyword if
.
if True:
print("Hello!")
The if statement runs code only if the boolean it's relying on is True
. It's like saying, if something is true, then do this.
"Hello!"
will display in the console if we set the boolean value to True
.
if True:
print("Hello!")
But what if we want to skip code? Here, setting the boolean to False
will skip the display statement.
if False:
print("Hello!")