How to Create a List of 100 Numbers in Python?

Estimated read time 1 min read

You can create a list of 100 numbers in Python in multiple ways. Here are some examples:

  1. Using a loop:
numbers = []
for i in range(1, 101):
    numbers.append(i)
  1. Using a list comprehension:
numbers = [i for i in range(1, 101)]
  1. Using the list() function with range():
numbers = list(range(1, 101))

All of these examples will create a list of 100 numbers ranging from 1 to 100. You can modify the starting and ending values to generate a list of numbers in any desired range.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply