Python Practice › Loop Programs › Program 69
First 20 natural numbers with while
Write a Python program to print the first 20 natural numbers using a while loop.
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Approach
- Count from 1 to 20.
Solution
n = 1while n <= 20: print(n, end=" ") n += 1print()Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Learn the concept
New to this topic? Read the lesson, then come back.