Suppose that I have a list x=[1, 2, 3, 4]
, it contains the sublists [1]
, [2]
, [3]
, [4]
, [1, 2]
, [2, 3]
, [3, 4]
, [1,2,3]
, [2,3,4]
and [1,2,3,4]
. But it does not contain something like [1, 3]
because there is a gap as 2 appears between 1 and 3 in x.
Does anybody know what the best way is to test if a list is contained within another list without gap? I have thought about a for-loop solution, but it might not be a very good solution. Thanks.