Challenge: Skip Even Numbers
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
continueto skip the current step and move on
Your task:
Use a
forloop to go through the numbers 1 to 10Check whether each number is even
Skip even numbers
Print only the numbers that are not skipped
💡 Things to keep in mind:
The
%operator can help you check even vs odd numberscontinueskips the rest of the loop for the current numberThe loop itself should still run from 1 to 10
When you click Run, your output should show only odd numbers.
Challenge: Skip Even Numbers
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
continueto skip the current step and move on
Your task:
Use a
forloop to go through the numbers 1 to 10Check whether each number is even
Skip even numbers
Print only the numbers that are not skipped
💡 Things to keep in mind:
The
%operator can help you check even vs odd numberscontinueskips the rest of the loop for the current numberThe loop itself should still run from 1 to 10
When you click Run, your output should show only odd numbers.