#sub list test 1
a = [1,1,2]
b = [0, 1,1,1,2,1]
#sub list test 2
c = [4,5]
d = [2,3,4,5,6]
if all(i in a for i in b):
print("Yes I have all the elements but not sure about their order :( ")
I have tried all()
or using counter()
from collections
module. I can't seem to figure it out how to check their order too.
source https://stackoverflow.com/questions/70488936/check-if-list-is-sublist-of-another-list-and-the-elements-are-in-the-same-order
Comments
Post a Comment