我必须检查 list1 是否包含在 list2 中。它还应该检查它是否也以该顺序出现在列表中。如果为真,则应返回真,否则应返回假。
def check(lst1, lst2):
for x in lst1:
for y in lst2:
xx = lst1.sort()
yy = lst2
if xx != yy:
return False
else:
return True
我对 for 循环感到困惑,而且我不知道从哪里去修复我的代码。请指点?
它应该做什么的例子:
check([4,0],[9,1,4,6,8,9])
True
check([1,2],[2,3,1])
False