I want to merge element in the list based on given start and stop index of tuple (non-overlap for tuple). I'll leave the indices that don't mention as it is. This is my example
ls = ['1', '2', '3', '4', '5', '6', '7']
merge = [(1, 3), (5, 7)]
Here, I want to merge index from [1:3]
together and [5:7]
together so the output should look something like following
['1', '23', '4', '5', '67']
I tried to loop using range(len(ls))
but it doesn't seem to be the right way to tackle this problem. Let me know if someone has simple way to solve this problem.