[Solved] How to transform a slice to a list of index in python? [closed]
You can use the indices method of the slice to generate a tuple that can be passed to range. You need to know the length of your instance though. For example: >>> sl = slice(2) # or wherever you get that from >>> length = 100 >>> list(range(*sl.indices(length))) [0, 1] 5 solved How to transform … Read more