get it on google playCreated with Sketch.
Python> If statement

If statement

We use an if statement to write code that responds to different situations. We recognize it by the keyword if.

if True:
  print("Hello!")

The if statement runs code only if it is evaluated as true. It's like saying, if something is true, then do this.

Let's make the evaluation true by simply using the boolean value True to display "Hello" in the console.

if True: 
  print("Hello!")

But what if we want to skip the code? In that case, we need the statement to evaluate as false.

Let's easily make the statement evaluate to false by simply using the boolean value False. Nothing will print.

if False:
  print("Hello!")
TRY IT ON THE APP