list to list of lists python code example
Example 1: convert list to list of lists on every n elements python
n = 5
my_list_of_lists = [my_list[i:i + n] for i in range(0, len(my_list), n)]
Example 2: convert list of list to list python
merged = list(itertools.chain.from_iterable(list2d))