I have the following problem. I have a list like:
>>> l = list(range(20))
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> # What I want:
>>> [[0, 1, 2, 3], [3, 4, 5, 6], [6, 7, 8, 9] , ...]
How can I get my list into such k pieces with length 4 in the most pythonic way? I feel like I miss something obvious here. I am fully aware of How do you split a list into evenly sized chunks? but still have no clue...
Thanks in advance!