Here is a direct solution. This is not as efficient as it could be, but it will be good if your lists are too long:
myarray = [2,5,1,7,3,8,1,2,3,4,5,7,4,9,1,2,3,5] for idx, a in enumerate(myarray): if myarray[idx:idx+4] == [a,a+1,a+2,a+3]: print([a, a+1,a+2,a+3]) break
source share