我一直在試圖做一個函數,可以採取兩個任何大小的列表(比如說,列表A和列表B),並看到列表B是否出現在列表中A,但是連續且以相同的順序。如果以上情況屬實,則返回True,否則返回False。蟒蛇 - 比較兩個列表,看看是否發生在另一個連續
例如,
A:[9,0,**1,2,3,4,5,6,**7,8] and B:[1,2,3,4,5,6] is successful
A:[1,2,0,3,4,0,5,6,0] and B:[1,2,3,4,5,6] is unsuccessful.
A:[1,2,3,4,5,6] and B [6,5,3,2,1,4] fails because despite having the same
numbers, they aren't in the same order
我試着這樣做使用嵌套循環到目前爲止並感到有點困惑,去哪裏
可能要看一看的https:/ /stackoverflow.com/questions/10106901/elegant-find-sub-list-in-list –
這是你所需要的: https://stackoverflow.com/questions/16579085/python-verifying-if-one-list-is-a-subset-of-the-other –