Question on lists

Dan dan at
Wed Jul 28 07:24:20 CEST 2004

I've got a SortedList class I wrote with a unique() member function that
does just this. I'm going to post it to the Python cookbook soon. If
you're interested I can send along a copy.


-----Original Message-----
From: at
[ at] On Behalf Of
Kristofer Pettijohn
Sent: Tuesday, July 27, 2004 8:27 PM
To: python-list at
Subject: Question on lists

My question is about lists:

Is there a way to remove duplicate items from a list that are
next to each other?


Performing the operation on ['a', 'b', 'c', 'c', 'd', 'd', 'd', 'e']
will return ['a', 'b', 'c', 'd', 'e']

Performing the operation on ['a', 'b', 'c', 'c', 'd', 'c', 'd', 'e']
will return ['a', 'b', 'c', 'd', 'c', 'd', 'e']

I'm guessing there is probably nothing internal that will do it, so
I may have to write something on my own - just thought I'd check
first ;)


Kristofer Pettijohn
kristofer at

More information about the Python-list mailing list