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

By Hardik Savani October 30, 2023 Category : Python

Hey Folks,

In this tutorial, you will learn python create list 1 to 100. I am going to show you about how to create a list from 1 to 100 in python. i will show you about python generate list 1 to 100. I explained simply step by step python create a list of 100 items.

If you are looking to generate list of numbers from 1 to 100 in python, there are several ways to create a list from 1 to 100 in python. here, I will give you two examples with range() and numpy library for creating new list numbers from 1 to 100 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 100 of numbers
myList = list(range(1, 101))
  
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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]

Example 2:

main.py

import numpy as np
  
# python create list of numbers from 1 to 100
myList = np.arange(1, 101, 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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]

I hope it can help you...

Tags :
Shares