I have a set of strings set1, and all the strings in set1 have a two specific substrings which I don\'t need and want to remove. Sample Input
set1
All you need is a bit of black magic!
>>> a = ["cherry.bad","pear.good", "apple.good"] >>> a = list(map(lambda x: x.replace('.good','').replace('.bad',''),a)) >>> a ['cherry', 'pear', 'apple']