Pythondex

Python Challenge

Print Even Numbers

EasyLoops

Write a Python program that prints all even numbers from 1 to 10 (inclusive), each on a new line. This challenge helps you understand how to use loops and conditional statements to filter numbers.

It’s a simple way to practice using the `if` condition and the modulo operator `%` to check for even numbers.

Constraints

  • Do not use any external libraries.
  • Use a `for` loop to iterate from 1 to 10.
  • Use an `if` condition to check for even numbers.

Examples

Output:

Hints

  • Remember that a number is even if `number % 2 == 0`.
  • Use `range(1, 11)` to include 10 in your loop.

Solution