How do I create a list with numbers between two values?

Here is an example of how you might create a list of numbers between two values in python:

start = 5
end = 10
my_list = list(range(start, end))

print(my_list)
# Output: [5, 6, 7, 8, 9]

In this example, the range(start, end) function generates a sequence of numbers from start up to, but not including, end. The list() function is then used to convert the range to a list.

Watch a course Python - The Practical Guide

Alternatively, a list comprehension can also be used to achieve this:

start = 5
end = 10

my_list = [x for x in range(start,end)]

print(my_list)

You can also generate a list of numbers with a specific step between each number using range function

my_list = list(range(0, 10, 2))
print(my_list)

Where step is the value to increment.