-2

Could someone please tell me what the statement in the 2nd line is doing? I cant find a similar example online. I think it is initializing Lst, but i cant quite picture what the list Lst will look like. Thanks

Lst = []
Lst = [ [] for i in range(65536)] 

3 Answers3

3

What’s happening here is that it’s creating a list of lists. However, the inner lists will all be empty and the outer list that contains the empty list will be of size 65536.

RohanP
  • 227
  • 1
  • 5
3

This is equivalent

Lst = []
for i in range(65536):
    Lst.append( [] )
Blue Print
  • 334
  • 2
  • 10
1

it creates a list of 65536 '[]'

Tom Planche
  • 101
  • 11