ItSolutionStuff.com

Python Create List from 1 to 10 Example

By Hardik Savani • October 30, 2023
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: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Create a List of Numbers from 1 to 100 in Python?

Read Now →

How to Create List of Numbers from Range in Python?

Read Now →

How to Remove All String Values from List in Python?

Read Now →

How to Remove All Numbers Values from List in Python?

Read Now →

How to Get Only String from a List in Python?

Read Now →

How to Get Only Numbers from a List in Python?

Read Now →

How to Get Only Negative Values in Python List?

Read Now →

How to Get Only Positive Values in Python List?

Read Now →

Python List Get All Items Less Than Some Value Example

Read Now →

Python List Get All Elements Greater Than Some Value Example

Read Now →

Python Convert List to String with Space Example

Read Now →

How to Get Last n Elements of a List in Python?

Read Now →

How to Convert List into String in Python?

Read Now →

Python Get Second Last Element of List Example

Read Now →