Python to print odd numbers between 1 to 10 using a while loop.

861
Python program to print odd numbers between 1 to 10 using while loop.

In this article, we are going to create Python to print odd numbers between 1 to 10 using a while loop. In computer programming, a loop is a set of statements that are repeated until a certain condition is satisfied. The basic purpose of the loop is to repeat the code according to our program requirements.

At first, we have given the number variable 1. After that, We use the while condition for odd numbers and give the statement in the next line. then we print the number. In the last line, we have to add 2 until the condition is satisfied.

Python to print odd numbers using while loop(Source code)

number = 1

while number <= 10:
  print(number, end=" ")
  number = number + 2

Output

1 3 5 7 9

In case of any problem ask me on social media

Also, Read

Python Program to Remove Empty Strings from a List

Python program will print 1 to 10 numbers using while loop

LEAVE A REPLY

Please enter your comment!
Please enter your name here