Learn about Print Numbers From 1 to 10 in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view of what’s actually happening.
Contents
Program to Print Numbers From 1 to 10 in Python
The below python code prints numbers from 1 to 10 using a for loop. You can change the value inside the for loop in order to print more or fewer numbers.
# Python program to print numbers from 1 to 10
print('Numbers from 1 to 10 are:')
for n in range(1, 11):
print(n, end=' ')
Output :
Numbers from 1 to 10 are:
1 2 3 4 5 6 7 8 9 10
Hope the above code works for you and Refer to the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Print Perfect Numbers in Given Range