[Tutor] how to remove the coming duplication

Asokan Pichai pasokan at talentsprint.com
Thu Nov 10 09:04:29 CET 2011

I was so miffed at not reading the OP's
mail carefully that I wrote a one liner.

Ok. Here it goes:

def no_adjacent_dup(lst):
       return [ x for x, y in zip(lst, lst[1:]) if x != y] + [lst[-1]]

:-) Enjoyed working that one out; but whether it is a good solution ....

Asokan Pichai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111110/d55d3832/attachment.html>

More information about the Tutor mailing list