3

Not sure if this has been asked, but essentially I have a list (let's say [1, 2, 3, 4, 5, 6, 7, 8]). I'm then given another list of indices from which I have to split the first list (let'say [3, 5]). The length of this second list can vary.

Now, I want the output to be (in this case) [[1, 2, 3], [4, 5], [6, 7, 8]].

I don't know how to do this, and thought there would be a one-liner for this, but I've searched SO and Google for ages and can't find anything :(

Thanks!

Adi219
  • 4,712
  • 2
  • 20
  • 43

0 Answers0