How to Create a List of Numbers from 1 to 100 in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Remove All String Values from List in Python?
- How to Remove All Numbers Values from List in Python?
- How to Get Only Numbers from a List in Python?
- How to Get Only Negative Values in Python List?
- Python List Get All Items Less Than Some Value Example
- Python List Get All Elements Greater Than Some Value Example
- How to Get Last n Elements of a List in Python?
- How to Get First 2, 3, 4, 5, 10, etc Elements from List in Python?
- How to Remove First n Elements from List in Python?
- Python List Replace Double Quotes with Single Example
- Python Pretty Print List of Dictionaries Example
- How to Convert List to Lowercase in Python?
- How to Convert List into String in Python?
- How to Remove null Values from the List in Python?