Try del
and slicing
. The worst time complexity is O(N^2)
.
sub_list=['a', int]
big_list=[1, 'a', int, 3, float, 'a', int, 5]
i=0
while i < len(big_list):
if big_list[i:i+len(sub_list)]==sub_list:
del big_list[i:i+len(sub_list)]
else:
i+=1
print(big_list)
result:
[1, 3, , 5]