如何创建一个名为
sublist()
的函数,该函数接受两个列表 list1
和 list2
作为参数,并返回True
如果 list1
是 list2
的子列表,否则返回False
。如果在 list1
中的数字按照它们在 list1
中出现的顺序出现在 list2
中,但不一定是连续的,则认为 list1
是 list2
的子列表。例如:>>> sublist([1, 12, 3],[25, 1, 30, 12, 3, 40])
True
>>> sublist([5, 90, 2],[90, 20, 5, 2, 17])
False