Python Create List from 1 to 1000 Example

By Hardik Savani October 30, 2023 Category : Python

Hey Developer,

This detailed guide will cover python create list 1 to 1000. This article goes in detailed on how to create a list from 1 to 1000 in python. I would like to share with you python generate list 1 to 1000. We will look at an example of python create a list of 1000 items.

If you are looking to generate list of numbers from 1 to 1000 in python, there are several ways to create a list from 1 to 1000 in python. here, I will give you two examples with range() and numpy library for creating new list numbers from 1 to 1000 in python. so, let's see the example code.

You can use these examples with python3 (Python 3) version.

let's see below a simple example with output:

Example 1:

main.py

# python create list 1 to 1000 of numbers
myList = list(range(1, 1001))
  
print(myList)

Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, ... 1000]

Example 2:

main.py

import numpy as np
  
# python create list of numbers from 1 to 1000
myList = np.arange(1, 1001, 1).tolist()
  
print(myList)

Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, ... 1000]

I hope it can help you...

Tags :
Shares