How to Sort Even Numbers Within a Given Range in Python


In this example, we will learn the methods to find out all even numbers in a given range in Python.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

lowerLimit = int(input("Please input the lower limit: "))
upperLimit = int(input("Please input the upper limit: "))
for i in range(lowerLimit, upperLimit + 1):
    if i % 2 == 0:
        print(i)

Output:

Please input the lower limit: 100
Please input the upper limit: 120
100
102
104
106
108
110
112
114
116
118
120
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement