To create a for loop 1 to 10 in Python, you can use the range() function in for loop. Read the following article for more information.
For loop 1 to 10 in Python
In Python, a for loop is used to iterate over an object (a list, a tuple, a dictionary, a set, or a string) until a condition is met. The for loop in Python is not precisely the same as that in other programming languages, and the function is not the same as that of the for loop in other object-oriented programming languages.
Use the range() function
To loop from 1 to 10 in a for loop you need to use Python’s built-in function range(). The range() function returns a sequence of numbers, starting at 0 and ending at a specified number, and the step is an optional argument.
Syntax:
range(start,end,step)
Parameters:
- start: starting value. The default is 0.
- end: end value.
- step: The argument specifies the increment from the starting value. The default is 1.
Note: The range(i) function prints a starting value of 0, so the ending value will be i-1.
Example:
- Use the range() function in the for loop to create a loop from 1 to 10.
print('For loop from 1 to 10, including 10:') # Use the range() function for i in range(1,11): print(i)
Output:
For loop from 1 to 10, including 10:
1
2
3
4
5
6
7
8
9
10
To create a for loop from 1 to 10, you need to pass the starting value as 1 and the ending value as 11 to return, including the value 10.
Example:
- Use the range() function in the for loop to create a loop from 1 to 10.
print('For loop from 1 to 10, excluding 10:') # Use the range() function for i in range(1,10): print(i)
Output:
For loop from 1 to 10, excluding 10:
1
2
3
4
5
6
7
8
9
If you don’t specify a starting value for the range() function, the default start value is 0. So the end value will be 10 – 1.
The for loop returns a different data type
In the form of a list:
Example
# The for loop from 1 to 10 is in the form of a list for i in range(10): print(list(range(10))) break
Output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In the form of a tuple:
Example
# The for loop from 1 to 10 is in the form of a tuple for i in range(10): print(tuple(range(10))) break
Output:
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Summary
This article will help if you want to create a for loop 1 to 10 in Python. If you have any questions about this article, please leave a comment below. I will answer your questions as possible. Thank you for reading!
Maybe you are interested:

My name is Jason Wilson, you can call me Jason. My major is information technology, and I am proficient in C++, Python, and Java. I hope my writings are useful to you while you study programming languages.
Name of the university: HHAU
Major: IT
Programming Languages: C++, Python, Java