+ 1
Lists in List (Python)
Hello Guys, i want to initialize Lists in a List, so i want it to look like this [[],[],...] but i want the amount of lists in the list to have a specific length of course. Is there a faster way than to initialize the big list and then append all the small lists? greeting and thanks for the help
1 ответ
+ 3
You can use a list comprehension to put a certain number of elements (in this case, empty lists) into a collection
list_of_lists = [[] for _ in range(10)]
print(list_of_lists)