...

/

Make Decisions

Make Decisions

Learn to control flow using decision-making.

Now it’s time to teach Python how to make decisions—just like you do every day.

Press + to interact


In this lesson, we’ll learn how to write programs that react to different conditions using if, else, and elif.


Try this:

Press + to interact
age = 18
if age >= 18:
print("You're an adult!")

Python checked the condition and ran the code only if it was true.

In Python, a colon (:) starts a block of code—like after an if statement. The indentationIndentation means adding spaces at the beginning of a line of code. Most often, we use 4 spaces for indentation. (the space before the next line) tells Python which lines belong to that block

Unlike some other languages, Python uses indentation to group ...