On 2009-12-11, Ed Keith <e_...@yahoo.com> wrote: > I have a problem and I am trying to find a solution to it that is both > efficient and elegant. > > I have a list call it 'l': > > l = ['asc', '*nbh*', 'jlsdjfdk', 'ikjh', '*jkjsdfjasd*', 'rewr']
> Notice that some of the items in the list start and end with > an '*'. I wish to construct a new list, call it 'n' which is > all the members of l that start and end with '*', with the > '*'s removed. > > So in the case above n would be ['nbh', 'jkjsdfjasd'] [s[1:-1] for s in l if (s[0] == s[-1] == '*')] -- Grant Edwards grante Yow! Used staples are good at with SOY SAUCE! visi.com -- http://mail.python.org/mailman/listinfo/python-list