Print all even numbers in a range - Python Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Our task is to print all even numbers within a given range. The simplest way to achieve this is by using a loop to iterate through the range and check each number for evenness. Let's explore some methods to do so.Using LoopWe can use a for loop with if conditional to check if a number is even. Python s = 1 e = 10 for i in range(s, e + 1): if i % 2 == 0: print(i) Output2 4 6 8 10 Explanation:We loop through all the numbers in the given range (s to e).The condition i % 2 == 0 checks if the number is even (i.e., divisible by 2).If the condition is True than print the number.Using List ComprehensionList comprehension provides a concise way to filter even numbers and print them directly. Python s = 1 e = 10 res = [i for i in range(s, e + 1) if i % 2 == 0] print(res) Output[2, 4, 6, 8, 10] Explanation:This list comprehension generates a list of numbers from s to e where i % 2 == 0 (i.e., the number is even).The result is a list of even numbers which is then printed.Using range() with StepThe built-in range() function can also be used efficiently to print even numbers by setting a step value of 2. This avoids the need for an extra if condition. Python s = 1 e = 10 for i in range(2, e + 1, 2): print(i) Output2 4 6 8 10 Explanation:The range(2, e+ 1, 2) generates numbers starting from 2 and increments by 2, this producing only even numbers.No need for an if condition as the range is already defined to only include even numbers.Related Articles:Python For LoopsList Comprehension in PythonPython range() function Comment More infoAdvertise with us Next Article Print even numbers in a list - Python S Shivam_k Follow Improve Article Tags : Python python-list Python list-programs Practice Tags : pythonpython-list Similar Reads Print all Negative Numbers in a Range - Python We are given a range we need to print all negative number within specific range. For example, we are given start and end point start, end = -5, 0 we need to print all numbers so that output should be -5 -4 -3 -2 -1.Using a loopWe can use a loop to iterate through a given range and check if each numb 3 min read Print all Negative Numbers in a Range - Python We are given a range we need to print all negative number within specific range. For example, we are given start and end point start, end = -5, 0 we need to print all numbers so that output should be -5 -4 -3 -2 -1.Using a loopWe can use a loop to iterate through a given range and check if each numb 3 min read Print all Negative Numbers in a Range - Python We are given a range we need to print all negative number within specific range. For example, we are given start and end point start, end = -5, 0 we need to print all numbers so that output should be -5 -4 -3 -2 -1.Using a loopWe can use a loop to iterate through a given range and check if each numb 3 min read Print even numbers in a list - Python Getting even numbers from a list in Python allows you to filter out all numbers that are divisible by 2. For example, given the list a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], you might want to extract the even numbers [2, 4, 6, 8, 10]. There are various efficient methods to extract even numbers from a li 3 min read Print even numbers in a list - Python Getting even numbers from a list in Python allows you to filter out all numbers that are divisible by 2. For example, given the list a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], you might want to extract the even numbers [2, 4, 6, 8, 10]. There are various efficient methods to extract even numbers from a li 3 min read Print even numbers in a list - Python Getting even numbers from a list in Python allows you to filter out all numbers that are divisible by 2. For example, given the list a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], you might want to extract the even numbers [2, 4, 6, 8, 10]. There are various efficient methods to extract even numbers from a li 3 min read Like