Your idea of ββstoring indexes instead of real substrings is good.
As for the mechanism, you should save (start, end) the numbers as a tuple of two integers:
index1 = [(0,3), (4,8)]
When you need to play a substring, write the code as follows:
pair = index1[0] # (0,3) sub = s[pair[0] : pair[1]] # 'ABC'
Nayuki
source share