In this article we will show you, How to write a Python Program to Print Odd Numbers from 1 to N using While Loop, and For Loop with example.

**TIP: **I suggest you to refer Odd or Even Program article to understand the logic behind Python Odd numbers.

## Python Program to Print Odd Numbers from 1 to N using For Loop

This Python program allows the user to enter the maximum limit value. Next, it is going to print odd numbers from 1 to user entered maximum limit value.

In this example, For Loop will make sure that the odd numbers are between 1 and maximum limit value.

# Python Program to Print Odd Numbers from 1 to N maximum = int(input(" Please Enter any Maximum Value : ")) for number in range(1, maximum + 1): if(number % 2 != 0): print("{0}".format(number))

**OUTPUT**

## Python Program to Print Odd Numbers from 1 to N without If

This code is same as above, but we altered for loop to eliminate If block.

If you observe closely, we started the range from 1 and we used the counter value as 2. It means, for the first iteration number = 1, second iteration number = 3 (not 2) so on.

# Python Program to Print Odd Numbers from 1 to N maximum = int(input(" Please Enter any Maximum Value : ")) for number in range(1, maximum + 1, 2): print("{0}".format(number))

**OUTPUT**

## Python Program to Print Odd Numbers using While Loop

In this python print odd numbers program, we just replaced the For Loop with While Loop.

# Python Program to Print Odd Numbers from 1 to N maximum = int(input(" Please Enter the Maximum Value : ")) number = 1 while number <= maximum: if(number % 2 != 0): print("{0}".format(number)) number = number + 1

**OUTPUT**

## Python Program to Print Odd Numbers from 1 to 100 using For Loop

This python print odd numbers program allows user to enter Minimum and maximum value. Next, it will print odd numbers between Minimum and maximum value.

# Python Program to Print Odd Numbers from Minimum to Maximum minimum = int(input(" Please Enter the Minimum Value : ")) maximum = int(input(" Please Enter the Maximum Value : ")) for number in range(minimum, maximum+1): if(number % 2 != 0): print("{0}".format(number))

**OUTPUT**