Removing a sublist from a list
问题 I have a list e.g. l1 = [1,2,3,4] and another list: l2 = [1,2,3,4,5,6,7,1,2,3,4] . I would like to check if l1 is a subset in l2 and if it is, then I want to delete these elements from l2 such that l2 would become [5,6,7,1,2,3,4] , where indexes 0-3 have been removed. Is there a pythonic way of doing this? I tried this: l1 = [1,2,3,4] l2 = [1,2,3,4,5,6,7,1,2,3,4] l3 = [] for i in l2: if i in l1: l3.append(i) -> prints [5,6,7] However I would like the output to be [5,6,7,1,2,3,4] . 回答1: Well,