Creating a list from 1 to 100 in Python can be done using the range()
function and list comprehension. Here are two examples:
Example 1:
numbers = list(range(1, 101)) print(numbers)
Output:
[1, 2, 3, 4, 5, …, 100]
Example 2:
numbers = [i for i in range(1, 101)] print(numbers)
Output:
[1, 2, 3, 4, 5, …, 100]