-1

I want to do the following :

l = list()
l[2] = 'two'

As expected, that does not work. It returns an out of range exception.

Is there any way to, let say, define a list with a length ?

vdegenne
  • 12,272
  • 14
  • 80
  • 106

1 Answers1

4

Try this one

  values = [None]*1000

In place of 1000 use your desired number.

Debobroto Das
  • 834
  • 6
  • 16