Skip to content
Home » Print Even and Odd in Given Range Python

Print Even and Odd in Given Range Python

Learn about Print Even and Odd in Given Range Python in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Print Even and Odd in Given Range Python

# Python program to print all even and odd numbers in given range 

# range
start = int(input('Start: '))
end = int(input('End: '))

for num in range(start, end + 1):
    # check number is odd or not
    if num % 2 == 0:
        print(num, end = ':Even ')
    else:
        print(num, end = ':Odd ')

Output:

Start: 1
End: 15
1:Odd 2:Even 3:Odd 4:Even 5:Odd 6:Even 7:Odd 8:Even 9:Odd 10:Even 11:Odd 12:Even 13:Odd 14:Even 15:Odd

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Even or odd Program in Python using Function