W3docs

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:

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

Create a list of numbers between two values in Python

python— editable, runs on the server

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.

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

Create a list of numbers between two values in Python using list comprehension

python— editable, runs on the server

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

Create a list of numbers between two values in Python by generating a list of numbers first

python— editable, runs on the server

Where step is the value to increment.