Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Print 1 to 10 with a while Loop

Python Print 1 to 10 with a while Loop

Document Object Reference Manual Python3 Examples

We will use Python's while loop to print the numbers from 1 to 10.while A loop keeps executing until the given condition is no longer satisfied.

Example

i

=

1

while

i

<=

10

:

   

print

(

i

)

    i +

=

1

Code analysis:

Output result:

1
2
3
4
5
6
7
8
9
10

Document Object Reference Manual Python3 Examples