I have a list with letters:
list1 = [abcdefghijk]
I have num = 3
and want to break list1
in parts of 3, i.e:
[[abc], [def], [ghi], [jk]]
My code is:
for i in range(0, len(list1), num):
chunks = [list1[i:i+num]]
I get wrong output:
chunks = ['k']
But I expect:
chunks = [[abc],[def],[ghi],[jk]]
I have gone through all the available solutions here. But they did not help. How should I fix this?