Suppose I have a list like this:
myList=['A','B','C','D','E','F','G','H','I','J','K']
So, suppose I want to process this list as n-batches. If n = 3
,
the I want a list called batchIdx
[(0,3),(4,7),(8,10)]
where each tuple points to the (start,end)
indices of myList.
myList
could be of variable length. THis is not simply dividing list into equally sized chunks. Its like using divmod()
.
Edit: I actually want to create a list that indexes into myList. I'll use those indices in a different part of my program.
What is the best way to implement this?