I know that it is possible to do it like this:
test_list = ['1','2','3','4','5','6','7','8','9','10']
x = 3
final_list= lambda test_list, x: [test_list[i:i+x] for i in range(0, len(test_list), x)]
output=final_list(test_list, x)
output is: [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'], ['10']]
but I have a bit different requirements. I should return this:
output is: [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'], ['8','9', '10']]
In other words, I should allow repeating of numbers in the final chunk. Is there a simple way to do it?