;

# Python Program to Print Odd Numbers from 1 to Nth Number or Between a Specific Range

###### Tutorialsrack 22/04/2020 Python

In this Python Program, we will learn how to print odd numbers from 1 to nth number or between a given specific range.

Here are some examples of the program to print Odd numbers from 1 to nth number or between a given specific Range.

### Program 1: Using For Loop

Program 1: Using For Loop

``````# Python Program to Print Odd Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))

print("Odd Number Between 1 to {0}: ".format(maxNum))
for number in range(1, maxNum+1):
if(number % 2 != 0):
print("{0}".format(number))
``````
##### Output

Enter the Maximum Value : 10

Odd Number Between 1 to 10:

1

3

5

7

9

### Program 2: Using For Loop Without IF Statement

Program 2: Using For Loop Without IF Statement

``````# Python Program to Print Odd Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))
print("Odd Number Between 1 to {0}: ".format(maxNum))
for number in range(1, maxNum+1, 2):
print("{0}".format(number))

``````
##### Output

Enter the Maximum Value : 10

Odd Number Between 1 to 10:

1

3

5

7

9

### Program 3: Using While Loop

Program 3: Using While Loop

``````# Python Program to Print Odd Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))
print("Odd Number Between 1 to {0}".format(maxNum))
number = 1

while number <= maxNum:
if(number % 2 != 0):
print("{0}".format(number))
number = number + 1
``````
##### Output

Enter the Maximum Value : 10

Odd Number Between 1 to 10

1

3

5

7

9

### Program 4: Between a Given Specific Range

Program 4: Between a Given Specific Range

``````# Python Program to Print Odd Numbers Within a Specific Range

# Take the Input From the User
minNum = int(input("Enter the Minimum Value: "))
maxNum = int(input("Enter the Maximum Value: "))
print("Odd Number Between {0} to {1}: ".format(minNum,maxNum))
for number in range(minNum, maxNum+1):
if(number % 2 != 0):
print("{0}".format(number))
``````
##### Output

Enter the Minimum Value: 8

Enter the Maximum Value: 20

Odd Number Between 8 to 20:

9

11

13

15

17

19