I need a string/list/generator/comprehension incantation.
malaclypse2 at gmail.com
Fri Apr 20 19:02:01 CEST 2007
On 4/20/07, Steven W. Orr <steveo at syslang.net> wrote:
> I really tried. I give up.
> Now I want something that's going to give me a string whose value is the
> set of all of the first letters of months. Order is not important.
>>> ''.join(set([s for s in calendar.month_abbr[1:]]))
> And for extra credit, I need the string whose value is the set of all of
> the letters of months minus the first letter.
I'm sure there must be a cleaner way to do this, but it works:
>>> ''.join(set(''.join([s[1:] for s in calendar.month_abbr[1:]])))
> E.g., 'ADFJMONS', 'acbeglonprutvy'
More information about the Python-list