[Tutor] how to remove the coming duplication

Asokan Pichai pasokan at talentsprint.com
Thu Nov 10 10:05:59 CET 2011


On Thu, Nov 10, 2011 at 2:07 PM, Peter Otten <__peter__ at web.de> wrote:

> Christian Witts wrote:
>
> > def remove_coming_duplication(a_list):
> >      return [element for idx, element in enumerate(a_list) if element !=
> > a_list[idx-1]]
>
> Beware of negative indices:
>
> >>> remove_coming_duplication([1, 2, 1])
> [2, 1] # should be [1, 2, 1]
>
>
I ran into that and hence I chose to zip, compare and add the last element

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


More information about the Tutor mailing list