Say I've got A = [1, 2, 3, 4] I want to have B = [(1,2), (2,3), (3,4)], so I can check if B contains (u,v). Already tried iterating from 0 to len(A)-1 checking every (A,A+1) but this seems to be inefficient. A = [1, 2, 3, 4] for i in range(len(A)-1): if A == u and A[i+1] == v: #assume true #assume false Having B as above would help in this problem and some others, I think. Continue reading...