Can anyone suggest a method to get local min in a list?
For example, I have a list [50, 50, 49, 49, 49, 50, 50, 50, 49, 49, 49, 48, 48, 48, 47, 47, 48, 48, 13, 12, 11, 10, 11, 12].
I want to get the answer [49, 47, 10], and the index.
I had tried, but I get the answer like [49, 50, 47, 48, 10, 11, 12].
Can someone help me to revise the code?
Thanks a lot.
for i in range(len(list)):
if (i != 0) & (i+1 != len(list)):
if (list[i] == list[i + 1]):
repeat += 1
elif (list[i] < list[i - 1]):
repeat = 1
continue
elif (list[i] < list[i + 1]):
group_list.append(list[i])