How to find all occurrences of an element in a list
index()
will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?
index()
will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?
I have a 2 dimensional NumPy array. I know how to get the maximum values over axes:
I want to split a string by a list of indices, where the split segments begin with one index and end before the next one.