【发布时间】:2017-12-27 14:00:52
【问题描述】:
我一直在尝试创建一个函数,它可以采用两个任意大小的列表(例如,列表 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
到目前为止,我已经尝试过使用嵌套循环来执行此操作,但对于去哪里有点困惑
【问题讨论】:
标签: python python-3.x list compare nested-loops