def chunks(lista, n):
inicio = 0
for i in range(n):
final = inicio + len(lista[i::n])
yield lista[inicio:final]
inicio = final
l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
print(list(chunks(l, 3)))
ZGVmIGNodW5rcyhsaXN0YSwgbik6CiAgICBpbmljaW8gPSAwCiAgICBmb3IgaSBpbiByYW5nZShuKToKICAgIAlmaW5hbCA9IGluaWNpbyArIGxlbihsaXN0YVtpOjpuXSkKICAgIAl5aWVsZCBsaXN0YVtpbmljaW86ZmluYWxdCiAgICAJaW5pY2lvID0gZmluYWwKICAgIAkKbCA9IFswLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5LCAxMCwgMTEsIDEyLCAxMywgMTQsIDE1XQpwcmludChsaXN0KGNodW5rcyhsLCAzKSkp
[[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]