I have a list of lists. Each element of the list is made in this way [id1, id2, timex, value]. Given two external numbers ex and lx (ex < lx), I want to: 1. Check each element of the list, and see if timex < ex. If I find an element in which timex < ex, then I can end everything. 2. If I don't find it, then I want to make another check, starting for the first element of the list, and see if I can find an element in which ex < timex < lx. 3. If I don't find what said in point 2, I want to make another control and check whether there is an element with timex > lx.
What I did is this. But I want to know if there is a better way to do it.
f1 = 0
f2 = 0
found = False       
                    # 1         
                    count = 0
                    while (found == False) and (count < len(Listx)):
                        if Listx[count][2] <= ex:
                            print "Found - 1"
                            f1 = Listx[count][0]
                            f2 = Listx[count][1]
                            Listx[count][2] = Listx[count][2] + dx
                            found = True
                        count = count + 1
                    # 2 
                    count = 0
                    while (found == False) and (count < len(Listx)):
                        if (Listx[count][2] > ex) and (Listx[count][2] <= lx):
                            print "Found - 2"
                            Listx[count][2] = Listx[count][2] + ex
                            f1 = Listx[count][0]
                            f2 = Listx[count][1]
                            found = True
                        count = count + 1
                    #3
                    count = 0   
                    while (found == False) and (count < len(Listx)):
                        if (Listx[count][1] < lx):
                            f1 = Listx[count][0]
                            f2 = Listx[count][1]
                            found = True
                        count = count + 1
 
     
    