Q:

Comparing a sequence of numbers in a python list

I would like to make a loop to take a number, compare with the next number and if the condition is true, replace this number by the next number and compare this number to the next until this number not fits more in the condition. 
I tried this code but the looping does not work.
list = [9,4,3,1,8,10,4,3,2]

for i,item in enumerate(list):
        p = item  
        while p > list[i+1]:
              p = list[i+1]            

        else:
              print(p)

A:

You can find the local minima (I want the output the number: 1 and 2. (the minimal point in a wave)) for your list:
>>> data = [9, 4, 3, 1, 8, 10, 4, 3, 2]

by adding infinity to both end so that the first and the last element will also be found as a minimum:
>>> padded = [float('inf')] + data + [float('inf')]

and comparing a value with the one to its left and its right:
>>> [v2 for v1, v2, v3 in zip(padded[:-2], padded[1:-1], padded[2:]) if v1 > v2 < v3]
[1, 2]

