Skip to content

Instantly share code, notes, and snippets.

@joedborg
Created October 28, 2016 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joedborg/c1f18c9f7f016033fed8d1d2d064967d to your computer and use it in GitHub Desktop.
Save joedborg/c1f18c9f7f016033fed8d1d2d064967d to your computer and use it in GitHub Desktop.
Look for a sequuence within a list
def is_seq_in_list(sequence, match):
for i, j in enumerate(sequence):
if sequence[i:len(match) + i] == match:
return True
return False
if __name__ == '__main__':
match = [1, 3, 4]
sequence = [2, 3, 6, 3, 8, 1, 3, 4, 8, 2]
is_seq_in_list(sequence, match)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment