I need a string/list/generator/comprehension incantation.

Steven W. Orr steveo at syslang.net
Fri Apr 20 12:42:40 EDT 2007


I really tried. I give up.

I got this one last time (for which I'm very grateful).

import calendar
months = dict([(month,ii) for ii,month in enumerate(calendar.month_abbr)][1:])

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.

And for extra credit, I need the string whose value is the set of all of 
the letters of months minus the first letter.

E.g., 'ADFJMONS', 'acbeglonprutvy'

  Thanks in advance to all the wizards out there. :-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the Python-list mailing list