Python ProgrammingPython Programming

Fastest way to create a list of n lists in Python

from itertools import repeat

thelist = [[[]] for i in repeat(None, 5)]
print(thelist)

empty_list = [[] for x in range(5)]
print(empty_list)
Output
[[[]], [[]], [[]], [[]], [[]]]
[[], [], [], [], []]