I have a long text, and I am trying to remove multiple substrings using start and end index. The problem here is that when I remove the first substring from the original text, the rest of the start and end indexes will be invalid. what is the most efficient way to do this?
def remove_substrings(text, indexes):
'''
indexes is a list containing start and end indexes.
indexes = ["3 5", "7 8"]
'''
return text