Home>
The bottom line is that you need to create a list from the interval n to the interval x , as here:
x= int (input ("End:"))
for i in range (n, x + 1):
print (i)
# Start: 2
# End: 6
# 2
# 3
# 4
# 5
# 6
But if I try to do the same, but with a list
a= []
n= list (input ("Start:"))
x= list (input ("End:"))
for i in range (n, x):
print (a [i])
then throws an error
Traceback (most recent call last):
for i in range (n, x):
TypeError: 'list' object cannot be interpreted as an integer
The end result should look like:
a= []
n= list (input ("Start:")) # 2
x= list (input ("End:")) # 6
for i in range (n, x + 1):
print (a [i])
# [2,3,4,5,6]
In general, the whole problem is solved in one line a= list (range (int (input ("Start:")), int (input ("End:")) + 1))
andreymal20210929 20:06:13
Answer # 1
I like this:
a= [_ for _ in range (int (input ("Start:")), int (input ("End:")) + 1)] print (a)
Input example:
Start: 5
End: 10
Sample output:
[5, 6, 7, 8, 9, 10]
please try to leave a little more detailed answers. you can complete the answer by clicking edit
aleksandr barakin20210929 05:31:52Using _ in this case is not very appropriate. This is usually the name of variables with which there is no further interaction, and you use its value to generate a list.
zaborschicov20210929 10:43:11 
Answer # 2
Can be shorter
a= [i for i in range (int (input ("Start:")), int (input ("End:")) + 1)]

Answer # 3
missed
append
:a= [] n= int (input ("Start:")) # 2 x= int (input ("End:")) # 6 for i in range (n, x + 1): a.append (i) print (a) # [2,3,4,5,6]
Related questions
 Help with a light loop in python
 Python does not see pip3 modules
 python : Why event from keyboard is unknown on key press
 python : Is it possible to format code without list and string methods?
 javascript : Python3.x different times are sent in the get request through the browser, where can this time be taken from?
 python : How to check the invertibility of a matrix inside a class
 python : How can I find the coordinates of those symbols that were not used?
 python : Calculate the number of products in each subfolder
 python : I can't parse links like https://www.wildberries.ru/catalog/0/search.aspx
 python : Determine the number of points that enters a circle of radius R and an arbitrary center of the circle (x0, y0) and disp
The range arguments can only be numbers, no need to try to cram lists into them. What was wrong with the working int (input (?
andreymal20210929 20:06:13