loop from 1 to 10 in python

To loop from 1 to 10 in python, we can use the range() function together with a for loop. The range() function generates a sequence of numbers, starting from the specified start value, increments by the specified step value, and stops before a specified end value.

In this case, we can use range(1, 11) to generate the sequence from 1 to 10, and loop over the numbers using a for loop as shown below:

main.py
for i in range(1, 11):
    print(i)
36 chars
3 lines

This will print the numbers 1 to 10, one per line.

gistlibby LogSnag