I need a string/list/generator/comprehension incantation.
jon+usenet at unequivocal.co.uk
Fri Apr 20 18:54:31 CEST 2007
In article <mailman.6789.1177087364.32031.python-list at python.org>, Steven W. Orr wrote:
> 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(m for m 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.
"".join(set("".join(m[1:] for m in calendar.month_abbr[1:])))
Those are the ways that are obvious to me anyway, maybe there are
better ways. If you actually want a set not a string, remove the
More information about the Python-list