If I have a list as:
x = [1,2,3,4,5,6,7,8,9,10]
Is there a function or package that lets you specify the length of the combinations you're interested in without losing the remaining elements of the list?
For example, if I was interested in all combinations of length 4, could I return something like:
[[1,2,3,4],[5,6,7,8],[9,10]]
[[1,2,3,4],[5,6,7,8],[9],[10]]
I have been using itertools.combination
to get the first list, which is great, but I'm looking for a way to keep the remaining list information into account.
NOTE: I'm not looking for anyone to write code for me to solve it if that's what's required. I'm just asking in case someone knows of a similar function that might help.