Learn about Find Odd Numbers in the 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.
Contents
Find Odd Numbers in the Range Python
# Python program to print all odd numbers in given range
# range inputs
start = int(input('Start: '))
end = int(input('End: '))
print('All odd number in the range')
for num in range(start, end + 1):
# check number is odd or not
if num % 2 != 0:
print(num, end = " ")
Output:
Start: 2 End: 15 All odd number in the range 3 5 7 9 11 13 15
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Check if the Number is Odd in Python using Function