Skip to content

Instantly share code, notes, and snippets.

@himaprasoonpt
Created February 9, 2019 13:50
Show Gist options
  • Save himaprasoonpt/b51f5a9a5d56d2e83b63aa2b7acdb829 to your computer and use it in GitHub Desktop.
Save himaprasoonpt/b51f5a9a5d56d2e83b63aa2b7acdb829 to your computer and use it in GitHub Desktop.
Check if a list is a sublist of another list (Not subset )
def contains_sublist(big_list, sub_list):
"""
:param big_list: list: bigger list to search in
:param sub_list: list: sub-list
:return: boolean: True if base_list contains sub_list, False otherwise
"""
try:
big_list.__str__().index(sub_list.__str__())
return True
except ValueError:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment