Problem:
I want to make a list of lists with a sub list string count of three. I tried it with technics for matrixes but so far it won't work.
I couldn't get it to count, create list, first element, second element, third element, create new list, insert fourth element, fifth element, sixth element, create new list...
It would be nice if the code would also work with a list length of items that can't be divided by 3. So like 8 strings in my source list.
Sample Data:
my_list = ['Item11', 'Item12', 'Item13', 'Item24', 'Item25', 'Item26', 'Item37', 'Item38', 'Item39']
What I've tried:
sublist = []
for mainlist in range(3):
# Append an empty sublist inside the list
mainlist.append([])
for item in my_list:
for sublist in mainlist:
sublist.append(item)
print(sublist)
Expected result:
my_list = [['Item11', 'Item12', 'Item13'], ['Item24', 'Item25', 'Item26'], ['Item37', 'Item38', 'Item39']]