In this program, we will print the first 20 natural numbers using a while loop.
Steps to solve the program
- Create a variable and assign its value equal to 1.
- While the value of the variable is less than 21 print the variable.
- Add 1 to the count variable after printing a number.
- Print the output.
count = 1
while count < 21:
print(count,end=" ")
count += 1
Output :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20