a = slice(2, 7) s = 'HelloWorld' print(a.indices(len(s))) for i in range(*a.indices(len(s))): print(s[i])