I have a string, and I have a list of positions of the substrings that I need to delete:
text = 'ab cd ef gh'
positions = [[2, 5], [8, 11]]
Every element of the list contains start and end position of substring. End position is exclusive, and start position is inclusive. So the string should be transformed to:
text = 'ab ef'
Length of the list with positions is unknown, so the soultion can't be just hardcoded.
Is there any effective way to delete multiple substrings by their positions? Positions can't overlap.
[2,5]?endindex inclusive or exclusive? You have asked a very unclear question and that too without showing what you have already tried to achieve the expected output.