Check if two items are in a list, in a particular order?
v = [1,2,3,4,3,1,2]
any([2,3] == v[i:i+2] for i in xrange(len(v) - 1))
While @PaoloCapriotti's version does the trick, this one is faster, because it stops parsing the v
as soon as a match is found.
This is probably a bit of a round about way to do it, but you could use (with your variable v above):
' 2, 3' in str(v)
[2, 3] in [v[i:i+2] for i in range(len(v) - 1)]