- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python program to print all odd numbers in a range

In this article, we will learn about the solution and approach to solve the given problem statement.

## Problem statement

Given a range, we need to print all the odd numbers in the given range.

The brute-force approach is discussed below −

Here we apply a range-based for loop which provides all the integers available in the input interval.

After this, a check condition for odd numbers is applied to filter all the even numbers.

This approach takes O(n) + constant time of comparison.

Now let’s see the implementation below −

## Example

start, end = 10, 29 # iteration for num in range(start, end + 1): # check if num % 2 != 0: print(num, end = " ")

## Output

11 13 15 17 19 21 23 25 27 29

All the variables and functions are declared in a global frame as shown in the figure below.

## Conclusion

In this article, we learned about the approach to print odd numbers in the input range.

- Related Questions & Answers
- Python program to print all even numbers in a range
- Golang Program to Print Odd Numbers Within a Given Range
- Python program to print odd numbers in a list
- Python Program to Find All Numbers which are Odd and Palindromes Between a Range of Numbers
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Program to count odd numbers in an interval range using Python
- Golang Program to Print all Numbers in a Range Divisible by a Given Number
- Print all Good numbers in given range in C++
- Python program to print all Prime numbers in an Interval
- Program to print all palindromes in a given range in C++
- Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
- C++ program to find numbers with K odd divisors in a given range
- Program to print prime numbers in a given range using C++ STL
- PHP program to find the sum of odd numbers within a given range
- Python program to print all Disarium numbers between 1 to 100

Advertisements