A for loop or while loop or range() function is the way to write a program to print the first 10 natural numbers in Python.
Program to print the first 10 natural numbers in Python
Simple example code display natural numbers from 1 to n.
Using for loop
It displays natural numbers from 1 to 10.
num = 10 for i in range(1, num + 1): print(i, end=" ")
Using while loop
i = 1 while i <= 10: print(i), i = i + 1
Do comment if you have any doubts or suggestions on this Python natural number code.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.