To create a list with the numbers from 1 to 100 using Python, we can use the range() function.

list_1_to_100 = range(1, 101)

You can also use a loop to create a list from 1 to 100 in Python.

list_1_to_100 = []

for x in range(1,101):
    list_1_to_100.append(x)

When working with numbers in a Python program, it’s possible you want to create a list from 1 to 100 in Python.

You can easily create a list of the numbers 1 to 100 with Python.

The easiest way to create a list of numbers in a range with Python is the range() function.

The range() function takes in 3 arguments. The first is the starting point, the second is the ending point, and the third argument is the step size.

For example, if I want all the numbers between 1 and 10, I’d call the range function in the following way.

numbers_1_to_10 = list(range(1,11))

To build a list with the numbers between 1 and 100, just pass 101 as the second argument of range().

Below is an example in Python which creates a list with numbers from 1 to 100.

list_1_to_100 = range(1, 101)

Using a Loop to Create a List from 1 to 100 in Python

We can also use a loop to create a list with the numbers from 1 to 100 in Python.

To create a list of the numbers from 1 to 100, you want to loop over all of the numbers between 1 and 100, and then append those numbers to a list.

Below is a simple for loop which creates a list of the numbers from 1 to 100 in Python.

list_1_to_100 = []

for x in range(1,101):
    list_1_to_100.append(x)

Hopefully this article has been useful for you to learn how to create a list from 1 to 100 with Python.

Categorized in:

Python,

Last Update: March 22, 2024