On May 20, 3:58 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > def compress(s): > seen = set() > return ''.join(c for c in s if c not in seen and (seen.add(c) or > True))
Slightly nicer is to move the set add out of the conditional... def compress(s): seen = set() return ''.join(seen.add(c) or c for c in s if c not in seen) I wouldn't write it this way though :) -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list