0

It may be a basic question, but there are things I do not understand. I would like to create a list from 0 to 99, but it will not be output as I expected.

list = range(5)

print(list)
# >>> range(0, 5)

I want to get the following list.

print(list)

# >>>[0,1,2,3,4,,...,98,99]
marmeladze
  • 6,468
  • 3
  • 24
  • 45
Shiro
  • 11
  • 1
  • 1

1 Answers1

-2

try this code:

list1 = []
for i in range(100):
    list1.append(i)
print (list1)
#print list for python 2.7
  • 2
    1. `list` shouldn't be a name for a variable 2. List comprehensions wold make it easier: l = [i for i in range(100)] – gonczor Apr 19 '17 at 08:56
  • 3
    Or just `list(range(100))`, but of course that only works if `list` is not redefined as some variable. – tobias_k Apr 19 '17 at 08:59