Skip to content

Instantly share code, notes, and snippets.

@JakeCowton
Last active April 29, 2021 11:35
Show Gist options
  • Save JakeCowton/35f09d1403616c2e7a17f760a09c8965 to your computer and use it in GitHub Desktop.
Save JakeCowton/35f09d1403616c2e7a17f760a09c8965 to your computer and use it in GitHub Desktop.
Determine if a given list is a sublist of another
def is_sublist(a: list, b: list):
return any(
[v == a[0] and b[i:i + len(a)] == a for i, v in enumerate(b)]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment