Created
February 9, 2019 13:50
-
-
Save himaprasoonpt/b51f5a9a5d56d2e83b63aa2b7acdb829 to your computer and use it in GitHub Desktop.
Check if a list is a sublist of another list (Not subset )
This file contains 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 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