Python Create List from 1 to 10 Example

By Hardik Savani October 30, 2023 Category : Python

Hi Guys,

This article goes in detailed on python create list 1 to 10. I explained simply about how to create a list from 1 to 10 in python. if you want to see an example of python generate list 1 to 10 then you are in the right place. if you want to see an example of python create a list of 10 items then you are in the right place. Let's get started with how to make a list in python from 1 to 10.

If you are looking to generate list of numbers from 1 to 10 in python, there are several ways to create a list from 1 to 10 in python. here, I will give you two examples with range() and numpy library for creating new list numbers from 1 to 10 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 10 of numbers
myList = list(range(1, 11))
  
print(myList)

Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 2:

main.py

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

Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

I hope it can help you...

Tags :
Shares