-1

I wanna know if some list contains whole list. for example,

[1, 2, 3, 4, 5]

from this list, it contains

[1, 2, 3]

like this. can i do this without any module?

신호진
  • 69
  • 1
  • 8

1 Answers1

0
list1 = [1,2,3]
list2 = [1, 2, 3, 4, 5]

result =  all(elem in list2  for elem in list1)

print(result)# True
Ahmed Alhallag
  • 311
  • 2
  • 11