Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
The First while Loop
course content

Course Content

Python Loops Tutorial

The First while LoopThe First while Loop

Let's proceed!

The while loop!

The while statement verifies a condition. The condition should yield a Boolean value, which can be either True or False.

If the condition evaluates to True, the while statement executes the statements contained within its block.

The while statement keeps reevaluating the condition with each iteration and continues to execute its block until the condition becomes False.

Take a look at the code below:

How does the code work?

Task

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Everything was clear?

Section 2. Chapter 1
toggle bottom row
some-alt