Python Split List menjadi potongan menggunakan metode iterTools
# Split a Python List into Chunks using itertools
from itertools import zip_longest
sample_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
chunk_size=2
result=list(zip_longest(*[iter(sample_list)]*chunk_size, fillvalue=''))
print(result)
chunked_list = [list(item) for item in list(zip_longest(*[iter(sample_list)]*chunk_size, fillvalue=''))]
print(chunked_list)
Gorgeous Gazelle