Мой профиль
ACTIVITY 19 / 50

While a condition is true

Try as many times as you need

Let’s understand

while repeats a block while its condition is true. Something must change inside the loop or it may never finish. In this workshop, use Stop if a program runs too long.

Listen to the explanation

Example

n = 0
while n < 2:
    print(n)
    n = n + 1
YOUR MISSION

Print 1, 2 and 3 on separate lines using while.

I need a hint

Start with n = 1; increase n by 1 after printing.

How to find an error
  1. Read the last line of the error message.
  2. Find the indicated line. Check quotes, parentheses and indentation.
  3. Change one thing and run again.

main.py

4 spaces

Your draft stays in this browser.

Result

Python
Your program’s output will appear here. Click Run.