Search⌘ K
AI Features

Challenge: Skip Even Numbers

Explore how to control loop execution in Python by using the continue statement to skip even numbers within a for loop. This lesson helps you understand condition checking and loop flow to print only odd numbers from 1 to 10, enhancing your ability to automate tasks with programming logic.

We'll cover the following...

Sometimes you want a loop to skip certain values instead of stopping completely.

You can do this by:

  • Checking a condition inside the loop

  • Using continue to skip the current step and move on

Your task:

  1. Use a for loop to go through the numbers 1 to 10

  2. Check whether each number is even

  3. Skip even numbers

  4. Print only the numbers that are not skipped

💡 Things to keep in mind:

  • The % operator can help you check even vs odd numbers

  • continue skips the rest of the loop for the current number

  • The loop itself should still run from 1 to 10

When you click Run, your output should show only odd numbers.

Python
# Write your code here.