Skip to content

Instantly share code, notes, and snippets.

@Hardtack
Last active August 29, 2015 14:01
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 Hardtack/cca4c0de2457cb0a65b1 to your computer and use it in GitHub Desktop.
Save Hardtack/cca4c0de2457cb0a65b1 to your computer and use it in GitHub Desktop.
def issublist(sublist, superlist):
if not sublist:
return True
idx = 0
first = sublist[0]
cnt = len(sublist)
while True:
try:
idx = superlist[idx + 1:].index(first) + idx + 1
except ValueError:
return False
if sublist == superlist[idx:idx + cnt]:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment