0Pricing
Mojo Academy · Lesson

Making Choices with if/else

Branch on conditions.

Code That Decides

Programs often need to choose a path. The if statement runs a block only when its condition is true, so your code can react to data. 🔀

Your First if

Write if, a condition, a colon, then an indented block. If the condition holds, Mojo runs the block; otherwise it skips it entirely.

if score > 90:
    print("Top marks!")

All lessons in this course

  1. Making Choices with if/else
  2. Looping with while
  3. Iterating with for and range
  4. break, continue, and Early Exit
← Back to Mojo Academy