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
1 3 5 7 9
In case of any problem ask me on social media