I would like to separate a list of 80 sets of coordinates in backets of 8 sets each.
This is what I tried. I found the indexes where the backets start. I sliced the list of coordinates between one index and the next. FInally, I used an if statement to create the final backet, since there is no 'next' index for the last index. Any ideas to improve this approach? Thank you.
nested_lst = [[0.5, 11.3, 5.1]]*80
indexes = list(range(len(nested_lst)))[::8]
backets = []
for i in range(len(indexes)):
if i != len(indexes) - 1:
backet = nested_lst[indexes[i]:indexes[i+1]]
else:
backet = nested_lst[indexes[i]:]
backets.append(backet)