some action that resarts the whole process
A poor way to think of an algorithm.
You're just filtering, i.e., removing duplicates.
And -- in Python -- you're happiest making copies, not trying to do del
. In general, there's very little call to use del
.
def unique( some_list ):
list_iter= iter(some_list)
prev= list_iter.next()
for item in list_iter:
if item != prev:
yield prev
prev= item
yield prev
list( unique( ['berry','||','||','||','pancake'] ) )