Created
October 28, 2016 14:46
-
-
Save joedborg/c1f18c9f7f016033fed8d1d2d064967d to your computer and use it in GitHub Desktop.
Look for a sequuence within a list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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