On Sun, 18 May 2008 19:06:10 +0100 "Matt Porter" <[EMAIL PROTECTED]> wrote:
> Hi guys, > > I'm trying to compress a string. > E.g: > "AAAABBBC" -> "ABC" Not that you need help anymore, but I decided to give it a try. Not as elegant as the one- and two-liners, but somewhat concise I guess. def compress(s): new = [s[:1]] for c in s[1:]: if c not in new: new.append(c) return ''.join(new) -- http://mail.python.org/mailman/listinfo/python-list