TypeError: slice indices must be integers or None or have an __index__ method

This error seems to be raised by Python in the used loop.
Could you post an executable code snippet to reproduce this issue?