On Thu, Nov 10, 2011 at 2:07 PM, Peter Otten <__pete...@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
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to