build a list of the numbers from 1 to 100 in python

To build a list of the numbers from 1 to 100 in Python, you can use the range function and a loop to iterate through the range and append each number to a list.

main.py
numbers = []  # create an empty list to store the numbers

for i in range(1, 101):  # iterate through the range of numbers from 1 to 100
    numbers.append(i)   # append each number to the list

print(numbers)  # print the list of numbers
239 chars
7 lines

Output:

main.py
[1, 2, 3, ..., 99, 100]
24 chars
2 lines

gistlibby LogSnag