Oct-16-2022, 06:36 AM
I love a (simple) challenge. It's possible that I'm missing something,
but the above seems rather complicated to me.
What is wrong with:
but the above seems rather complicated to me.
What is wrong with:
film = ["12", "11", "11", "11", "17", "22", "22", "22", "22", "23", "24", "24", "24", "24"] oldvalue = film[0] startidx = 0 start_end = [] for idx,value in enumerate (film): if value != oldvalue: start_end.append([startidx,idx-1]) startidx = idx oldvalue = value start_end.append([startidx,idx]) print(start_end)
Output:[[0, 0], [1, 3], [4, 4], [5, 8], [9, 9], [10, 13]]
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.