How do I create a function sublist() that takes two lists, list1 and list2, and returns True if list1 is a s
def sublist(a, b):
"if set_a is not subset of set_b then obvious answer is False"
if not set(a).issubset(set(b)):
return False
n = 0
for i in a:
if i in b[n:]:
"+1 is needed to skip consecutive duplicates, i.e. sublist([2,1,1],[2,1]) = False"
"if +1 is absent then sublist([2,1,1],[2,1]) = True"
"choose to use or not to use +1 according to your needs"
n += b[n:].index(i) + 1
else:
return False
return True