Python Practice › Loop Programs › Program 69

First 20 natural numbers with while

EasyLoop Programs · 69 of 90

Write a Python program to print the first 20 natural numbers using a while loop.

Advertisement
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 

Approach

  1. Count from 1 to 20.

Solution

Python
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 
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More loop programs

← All 90 Loop Programs