相关疑难解决方法(0)

检查Python中是否存在切片列表

我想编写一个函数来确定子列表是否存在于更大的列表中.

list1 = [1,0,1,1,1,0,0]
list2 = [1,0,1,0,1,0,1]

#Should return true
sublistExists(list1, [1,1,1])

#Should return false
sublistExists(list2, [1,1,1])
Run Code Online (Sandbox Code Playgroud)

有没有Python功能可以做到这一点?

python list

36
推荐指数
2
解决办法
3万
查看次数

标签 统计

list ×1

python ×1