• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / Create List of Numbers from 1 to 100 Using Python

Create List of Numbers from 1 to 100 Using Python

August 5, 2022 Leave a Comment

To create a list with the numbers from 1 to 100 using Python, we can use the range() function.

list_1_to_100 = range(1, 101)

You can also use a loop to create a list from 1 to 100 in Python.

list_1_to_100 = []

for x in range(1,101):
    list_1_to_100.append(x)

When working with numbers in a Python program, it’s possible you want to create a list from 1 to 100 in Python.

You can easily create a list of the numbers 1 to 100 with Python.

The easiest way to create a list of numbers in a range with Python is the range() function.

The range() function takes in 3 arguments. The first is the starting point, the second is the ending point, and the third argument is the step size.

For example, if I want all the numbers between 1 and 10, I’d call the range function in the following way.

numbers_1_to_10 = list(range(1,11))

To build a list with the numbers between 1 and 100, just pass 101 as the second argument of range().

Below is an example in Python which creates a list with numbers from 1 to 100.

list_1_to_100 = range(1, 101)

Using a Loop to Create a List from 1 to 100 in Python

We can also use a loop to create a list with the numbers from 1 to 100 in Python.

To create a list of the numbers from 1 to 100, you want to loop over all of the numbers between 1 and 100, and then append those numbers to a list.

Below is a simple for loop which creates a list of the numbers from 1 to 100 in Python.

list_1_to_100 = []

for x in range(1,101):
    list_1_to_100.append(x)

Hopefully this article has been useful for you to learn how to create a list from 1 to 100 with Python.

Other Articles You'll Also Like:

  • 1.  Get pandas Series First Element in Python
  • 2.  Python Logging Timestamp – Print Current Time to Console
  • 3.  islower Python – Check if All Letters in String Are Lowercase
  • 4.  How to Split List in Half Using Python
  • 5.  Python Round to Nearest 10 With round() Function
  • 6.  Get Day Name from Datetime in pandas DataFrame
  • 7.  Examples of Recursion in Python
  • 8.  How to Output XLSX File from Pandas to Remote Server Using Paramiko FTP
  • 9.  Create Empty List in Python
  • 10.  Using Python to Remove Quotes from String

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy