On 6/18/2009 7:23 AM karma said...
Hi Robert,

Thanks for the link. However, I am looking for eliminating consecutive
duplicates rather than all duplicates - my example wasn't clear,
apologies for that.

x=[1,1,1,3,2,2,2,4,4,2,2]

[1 ,3 ,2 ,4 ,2 ]

Something like

[ ii for ii,jj in zip(x,x[1:]+[-1]) if jj != ii]

Emile

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to